1use std::borrow::Cow;
3use std::fmt;
4use std::ops::Not;
5
6use rustc_abi::ExternAbi;
7use rustc_ast::attr::AttributeExt;
8use rustc_ast::token::DocFragmentKind;
9use rustc_ast::util::parser::ExprPrecedence;
10use rustc_ast::{
11 self as ast, FloatTy, InlineAsmOptions, InlineAsmTemplatePiece, IntTy, Label, LitIntType,
12 LitKind, TraitObjectSyntax, UintTy, UnsafeBinderCastKind, join_path_idents,
13};
14pub use rustc_ast::{
15 AssignOp, AssignOpKind, AttrId, AttrStyle, BinOp, BinOpKind, BindingMode, BorrowKind,
16 BoundConstness, BoundPolarity, ByRef, CaptureBy, DelimArgs, ImplPolarity, IsAuto,
17 MetaItemInner, MetaItemLit, Movability, Mutability, Pinnedness, UnOp,
18};
19use rustc_data_structures::fingerprint::Fingerprint;
20use rustc_data_structures::sorted_map::SortedMap;
21use rustc_data_structures::steal::Steal;
22use rustc_data_structures::tagged_ptr::TaggedRef;
23use rustc_data_structures::unord::UnordMap;
24use rustc_error_messages::{DiagArgValue, IntoDiagArg};
25use rustc_index::IndexVec;
26use rustc_macros::{Decodable, Encodable, StableHash};
27use rustc_span::def_id::LocalDefId;
28use rustc_span::{
29 BytePos, DUMMY_SP, DesugaringKind, ErrorGuaranteed, Ident, LocalExpnId, Span, Spanned, Symbol,
30 kw, sym,
31};
32use rustc_target::asm::InlineAsmRegOrRegClass;
33use smallvec::SmallVec;
34use thin_vec::ThinVec;
35use tracing::debug;
36
37use crate::attrs::AttributeKind;
38use crate::def::{CtorKind, DefKind, MacroKinds, PerNS, Res};
39use crate::def_id::{DefId, LocalDefIdMap};
40pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId};
41use crate::intravisit::{FnKind, VisitorExt};
42use crate::lints::DelayedLints;
43
44#[derive(#[automatically_derived]
impl ::core::fmt::Debug for AngleBrackets {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
AngleBrackets::Missing => "Missing",
AngleBrackets::Empty => "Empty",
AngleBrackets::Full => "Full",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for AngleBrackets { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AngleBrackets {
#[inline]
fn clone(&self) -> AngleBrackets { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for AngleBrackets {
#[inline]
fn eq(&self, other: &AngleBrackets) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for AngleBrackets {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
AngleBrackets {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
AngleBrackets::Missing => {}
AngleBrackets::Empty => {}
AngleBrackets::Full => {}
}
}
}
};StableHash)]
45pub enum AngleBrackets {
46 Missing,
48 Empty,
50 Full,
52}
53
54#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LifetimeSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
LifetimeSource::Reference =>
::core::fmt::Formatter::write_str(f, "Reference"),
LifetimeSource::Path { angle_brackets: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Path",
"angle_brackets", &__self_0),
LifetimeSource::OutlivesBound =>
::core::fmt::Formatter::write_str(f, "OutlivesBound"),
LifetimeSource::PreciseCapturing =>
::core::fmt::Formatter::write_str(f, "PreciseCapturing"),
LifetimeSource::Other =>
::core::fmt::Formatter::write_str(f, "Other"),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for LifetimeSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeSource {
#[inline]
fn clone(&self) -> LifetimeSource {
let _: ::core::clone::AssertParamIsClone<AngleBrackets>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LifetimeSource {
#[inline]
fn eq(&self, other: &LifetimeSource) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(LifetimeSource::Path { angle_brackets: __self_0 },
LifetimeSource::Path { angle_brackets: __arg1_0 }) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LifetimeSource {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<AngleBrackets>;
}
}Eq, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
LifetimeSource {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
LifetimeSource::Reference => {}
LifetimeSource::Path { angle_brackets: ref __binding_0 } =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
}
LifetimeSource::OutlivesBound => {}
LifetimeSource::PreciseCapturing => {}
LifetimeSource::Other => {}
}
}
}
};StableHash)]
55pub enum LifetimeSource {
56 Reference,
58
59 Path { angle_brackets: AngleBrackets },
62
63 OutlivesBound,
65
66 PreciseCapturing,
68
69 Other,
76}
77
78#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LifetimeSyntax {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
LifetimeSyntax::Implicit => "Implicit",
LifetimeSyntax::ExplicitAnonymous => "ExplicitAnonymous",
LifetimeSyntax::ExplicitBound => "ExplicitBound",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for LifetimeSyntax { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeSyntax {
#[inline]
fn clone(&self) -> LifetimeSyntax { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LifetimeSyntax {
#[inline]
fn eq(&self, other: &LifetimeSyntax) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LifetimeSyntax {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
LifetimeSyntax {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
LifetimeSyntax::Implicit => {}
LifetimeSyntax::ExplicitAnonymous => {}
LifetimeSyntax::ExplicitBound => {}
}
}
}
};StableHash)]
79pub enum LifetimeSyntax {
80 Implicit,
82
83 ExplicitAnonymous,
85
86 ExplicitBound,
88}
89
90impl From<Ident> for LifetimeSyntax {
91 fn from(ident: Ident) -> Self {
92 let name = ident.name;
93
94 if name == sym::empty {
95 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("A lifetime name should never be empty")));
};unreachable!("A lifetime name should never be empty");
96 } else if name == kw::UnderscoreLifetime {
97 LifetimeSyntax::ExplicitAnonymous
98 } else {
99 if true {
if !name.as_str().starts_with('\'') {
::core::panicking::panic("assertion failed: name.as_str().starts_with(\'\\\'\')")
};
};debug_assert!(name.as_str().starts_with('\''));
100 LifetimeSyntax::ExplicitBound
101 }
102 }
103}
104
105#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Lifetime {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Lifetime",
"hir_id", &self.hir_id, "ident", &self.ident, "kind", &self.kind,
"source", &self.source, "syntax", &&self.syntax)
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Lifetime { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Lifetime {
#[inline]
fn clone(&self) -> Lifetime {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<LifetimeKind>;
let _: ::core::clone::AssertParamIsClone<LifetimeSource>;
let _: ::core::clone::AssertParamIsClone<LifetimeSyntax>;
*self
}
}Clone, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Lifetime {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Lifetime {
hir_id: ref __binding_0,
ident: ref __binding_1,
kind: ref __binding_2,
source: ref __binding_3,
syntax: ref __binding_4 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
156#[repr(align(4))]
164pub struct Lifetime {
165 #[stable_hash(ignore)]
166 pub hir_id: HirId,
167
168 pub ident: Ident,
172
173 pub kind: LifetimeKind,
175
176 pub source: LifetimeSource,
179
180 pub syntax: LifetimeSyntax,
183}
184
185#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ParamName {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ParamName::Plain(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Plain",
&__self_0),
ParamName::Error(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Error",
&__self_0),
ParamName::Fresh => ::core::fmt::Formatter::write_str(f, "Fresh"),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for ParamName { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ParamName {
#[inline]
fn clone(&self) -> ParamName {
let _: ::core::clone::AssertParamIsClone<Ident>;
*self
}
}Clone, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for ParamName {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ParamName::Plain(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ParamName::Error(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ParamName::Fresh => {}
}
}
}
};StableHash)]
186pub enum ParamName {
187 Plain(Ident),
189
190 Error(Ident),
196
197 Fresh,
212}
213
214impl ParamName {
215 pub fn ident(&self) -> Ident {
216 match *self {
217 ParamName::Plain(ident) | ParamName::Error(ident) => ident,
218 ParamName::Fresh => Ident::with_dummy_span(kw::UnderscoreLifetime),
219 }
220 }
221}
222
223#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LifetimeKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
LifetimeKind::Param(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Param",
&__self_0),
LifetimeKind::ImplicitObjectLifetimeDefault =>
::core::fmt::Formatter::write_str(f,
"ImplicitObjectLifetimeDefault"),
LifetimeKind::Error(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Error",
&__self_0),
LifetimeKind::Infer =>
::core::fmt::Formatter::write_str(f, "Infer"),
LifetimeKind::Static =>
::core::fmt::Formatter::write_str(f, "Static"),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for LifetimeKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeKind {
#[inline]
fn clone(&self) -> LifetimeKind {
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LifetimeKind {
#[inline]
fn eq(&self, other: &LifetimeKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(LifetimeKind::Param(__self_0), LifetimeKind::Param(__arg1_0))
=> __self_0 == __arg1_0,
(LifetimeKind::Error(__self_0), LifetimeKind::Error(__arg1_0))
=> __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LifetimeKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<LocalDefId>;
let _: ::core::cmp::AssertParamIsEq<ErrorGuaranteed>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for LifetimeKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
LifetimeKind::Param(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
LifetimeKind::Error(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for LifetimeKind
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
LifetimeKind::Param(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
LifetimeKind::ImplicitObjectLifetimeDefault => {}
LifetimeKind::Error(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
LifetimeKind::Infer => {}
LifetimeKind::Static => {}
}
}
}
};StableHash)]
224pub enum LifetimeKind {
225 Param(LocalDefId),
227
228 ImplicitObjectLifetimeDefault,
240
241 Error(ErrorGuaranteed),
244
245 Infer,
249
250 Static,
252}
253
254impl LifetimeKind {
255 fn is_elided(&self) -> bool {
256 match self {
257 LifetimeKind::ImplicitObjectLifetimeDefault | LifetimeKind::Infer => true,
258
259 LifetimeKind::Error(..) | LifetimeKind::Param(..) | LifetimeKind::Static => false,
264 }
265 }
266}
267
268impl fmt::Display for Lifetime {
269 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
270 self.ident.name.fmt(f)
271 }
272}
273
274impl Lifetime {
275 pub fn new(
276 hir_id: HirId,
277 ident: Ident,
278 kind: LifetimeKind,
279 source: LifetimeSource,
280 syntax: LifetimeSyntax,
281 ) -> Lifetime {
282 let lifetime = Lifetime { hir_id, ident, kind, source, syntax };
283
284 #[cfg(debug_assertions)]
286 match (lifetime.is_elided(), lifetime.is_anonymous()) {
287 (false, false) => {} (false, true) => {} (true, true) => {} (true, false) => { ::core::panicking::panic_fmt(format_args!("bad Lifetime")); }panic!("bad Lifetime"),
291 }
292
293 lifetime
294 }
295
296 pub fn is_elided(&self) -> bool {
297 self.kind.is_elided()
298 }
299
300 pub fn is_anonymous(&self) -> bool {
301 self.ident.name == kw::UnderscoreLifetime
302 }
303
304 pub fn is_implicit(&self) -> bool {
305 #[allow(non_exhaustive_omitted_patterns)] match self.syntax {
LifetimeSyntax::Implicit => true,
_ => false,
}matches!(self.syntax, LifetimeSyntax::Implicit)
306 }
307
308 pub fn is_static(&self) -> bool {
309 self.kind == LifetimeKind::Static
310 }
311
312 pub fn suggestion(&self, new_lifetime: &str) -> (Span, String) {
313 use LifetimeSource::*;
314 use LifetimeSyntax::*;
315
316 if true {
if !new_lifetime.starts_with('\'') {
::core::panicking::panic("assertion failed: new_lifetime.starts_with(\'\\\'\')")
};
};debug_assert!(new_lifetime.starts_with('\''));
317
318 match (self.syntax, self.source) {
319 (ExplicitBound | ExplicitAnonymous, _) => (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", new_lifetime))
})format!("{new_lifetime}")),
321
322 (Implicit, Path { angle_brackets: AngleBrackets::Full }) => {
324 (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}, ", new_lifetime))
})format!("{new_lifetime}, "))
325 }
326
327 (Implicit, Path { angle_brackets: AngleBrackets::Empty }) => {
329 (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", new_lifetime))
})format!("{new_lifetime}"))
330 }
331
332 (Implicit, Path { angle_brackets: AngleBrackets::Missing }) => {
334 (self.ident.span.shrink_to_hi(), ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<{0}>", new_lifetime))
})format!("<{new_lifetime}>"))
335 }
336
337 (Implicit, Reference) => (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", new_lifetime))
})format!("{new_lifetime} ")),
339
340 (Implicit, source) => {
341 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("can\'t suggest for a implicit lifetime of {0:?}",
source)));
}unreachable!("can't suggest for a implicit lifetime of {source:?}")
342 }
343 }
344 }
345}
346
347#[derive(#[automatically_derived]
impl<'hir, R: ::core::fmt::Debug> ::core::fmt::Debug for Path<'hir, R> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "Path", "span",
&self.span, "res", &self.res, "segments", &&self.segments)
}
}Debug, #[automatically_derived]
impl<'hir, R: ::core::clone::Clone> ::core::clone::Clone for Path<'hir, R> {
#[inline]
fn clone(&self) -> Path<'hir, R> {
Path {
span: ::core::clone::Clone::clone(&self.span),
res: ::core::clone::Clone::clone(&self.res),
segments: ::core::clone::Clone::clone(&self.segments),
}
}
}Clone, #[automatically_derived]
impl<'hir, R: ::core::marker::Copy> ::core::marker::Copy for Path<'hir, R> { }Copy, const _: () =
{
impl<'hir, R> ::rustc_data_structures::stable_hash::StableHash for
Path<'hir, R> where
R: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Path {
span: ref __binding_0,
res: ref __binding_1,
segments: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
351pub struct Path<'hir, R = Res> {
352 pub span: Span,
353 pub res: R,
355 pub segments: &'hir [PathSegment<'hir>],
357}
358
359pub type UsePath<'hir> = Path<'hir, PerNS<Option<Res>>>;
361
362impl Path<'_> {
363 pub fn is_global(&self) -> bool {
364 self.segments.first().is_some_and(|segment| segment.ident.name == kw::PathRoot)
365 }
366}
367
368#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PathSegment<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["ident", "hir_id", "res", "args", "infer_args",
"delegation_child_segment"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.hir_id, &self.res, &self.args,
&self.infer_args, &&self.delegation_child_segment];
::core::fmt::Formatter::debug_struct_fields_finish(f, "PathSegment",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PathSegment<'hir> {
#[inline]
fn clone(&self) -> PathSegment<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Res>;
let _:
::core::clone::AssertParamIsClone<Option<&'hir GenericArgs<'hir>>>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PathSegment<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
PathSegment<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
PathSegment {
ident: ref __binding_0,
hir_id: ref __binding_1,
res: ref __binding_2,
args: ref __binding_3,
infer_args: ref __binding_4,
delegation_child_segment: ref __binding_5 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{}
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
371pub struct PathSegment<'hir> {
372 pub ident: Ident,
374 #[stable_hash(ignore)]
375 pub hir_id: HirId,
376 pub res: Res,
377
378 pub args: Option<&'hir GenericArgs<'hir>>,
384
385 pub infer_args: bool,
390
391 pub delegation_child_segment: bool,
395}
396
397impl<'hir> PathSegment<'hir> {
398 pub fn new(ident: Ident, hir_id: HirId, res: Res) -> PathSegment<'hir> {
400 PathSegment {
401 ident,
402 hir_id,
403 res,
404 infer_args: true,
405 args: None,
406 delegation_child_segment: false,
407 }
408 }
409
410 pub fn invalid() -> Self {
411 Self::new(Ident::dummy(), HirId::INVALID, Res::Err)
412 }
413
414 pub fn args(&self) -> &GenericArgs<'hir> {
415 if let Some(ref args) = self.args { args } else { GenericArgs::NONE }
416 }
417}
418
419#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for ConstItemRhs<'hir> {
#[inline]
fn clone(&self) -> ConstItemRhs<'hir> {
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ConstItemRhs<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for ConstItemRhs<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ConstItemRhs::Body(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Body",
&__self_0),
ConstItemRhs::TypeConst(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TypeConst", &__self_0),
}
}
}Debug, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ConstItemRhs<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ConstItemRhs::Body(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ConstItemRhs::TypeConst(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
420pub enum ConstItemRhs<'hir> {
421 Body(BodyId),
422 TypeConst(&'hir ConstArg<'hir>),
423}
424
425impl<'hir> ConstItemRhs<'hir> {
426 pub fn hir_id(&self) -> HirId {
427 match self {
428 ConstItemRhs::Body(body_id) => body_id.hir_id,
429 ConstItemRhs::TypeConst(ct_arg) => ct_arg.hir_id,
430 }
431 }
432
433 pub fn span<'tcx>(&self, tcx: impl crate::intravisit::HirTyCtxt<'tcx>) -> Span {
434 match self {
435 ConstItemRhs::Body(body_id) => tcx.hir_body(*body_id).value.span,
436 ConstItemRhs::TypeConst(ct_arg) => ct_arg.span,
437 }
438 }
439}
440
441#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
ConstArg<'hir, Unambig> {
#[inline]
fn clone(&self) -> ConstArg<'hir, Unambig> {
ConstArg {
hir_id: ::core::clone::Clone::clone(&self.hir_id),
kind: ::core::clone::Clone::clone(&self.kind),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
ConstArg<'hir, Unambig> {
}Copy, #[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
ConstArg<'hir, Unambig> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "ConstArg",
"hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
}
}Debug, const _: () =
{
impl<'hir, Unambig> ::rustc_data_structures::stable_hash::StableHash
for ConstArg<'hir, Unambig> where
Unambig: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ConstArg {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
455#[repr(C)]
456pub struct ConstArg<'hir, Unambig = ()> {
457 #[stable_hash(ignore)]
458 pub hir_id: HirId,
459 pub kind: ConstArgKind<'hir, Unambig>,
460 pub span: Span,
461}
462
463impl<'hir> ConstArg<'hir, AmbigArg> {
464 pub fn as_unambig_ct(&self) -> &ConstArg<'hir> {
475 let ptr = self as *const ConstArg<'hir, AmbigArg> as *const ConstArg<'hir, ()>;
478 unsafe { &*ptr }
479 }
480}
481
482impl<'hir> ConstArg<'hir> {
483 pub fn try_as_ambig_ct(&self) -> Option<&ConstArg<'hir, AmbigArg>> {
489 if let ConstArgKind::Infer(()) = self.kind {
490 return None;
491 }
492
493 let ptr = self as *const ConstArg<'hir> as *const ConstArg<'hir, AmbigArg>;
497 Some(unsafe { &*ptr })
498 }
499}
500
501impl<'hir, Unambig> ConstArg<'hir, Unambig> {
502 pub fn anon_const_hir_id(&self) -> Option<HirId> {
503 match self.kind {
504 ConstArgKind::Anon(ac) => Some(ac.hir_id),
505 _ => None,
506 }
507 }
508}
509
510#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
ConstArgKind<'hir, Unambig> {
#[inline]
fn clone(&self) -> ConstArgKind<'hir, Unambig> {
match self {
ConstArgKind::Tup(__self_0) =>
ConstArgKind::Tup(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Path(__self_0) =>
ConstArgKind::Path(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Anon(__self_0) =>
ConstArgKind::Anon(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Struct(__self_0, __self_1) =>
ConstArgKind::Struct(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
ConstArgKind::TupleCall(__self_0, __self_1) =>
ConstArgKind::TupleCall(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
ConstArgKind::Array(__self_0) =>
ConstArgKind::Array(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Error(__self_0) =>
ConstArgKind::Error(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Infer(__self_0) =>
ConstArgKind::Infer(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Literal { lit: __self_0, negated: __self_1 } =>
ConstArgKind::Literal {
lit: ::core::clone::Clone::clone(__self_0),
negated: ::core::clone::Clone::clone(__self_1),
},
}
}
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
ConstArgKind<'hir, Unambig> {
}Copy, #[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
ConstArgKind<'hir, Unambig> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ConstArgKind::Tup(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tup",
&__self_0),
ConstArgKind::Path(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
&__self_0),
ConstArgKind::Anon(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Anon",
&__self_0),
ConstArgKind::Struct(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Struct",
__self_0, &__self_1),
ConstArgKind::TupleCall(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"TupleCall", __self_0, &__self_1),
ConstArgKind::Array(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Array",
&__self_0),
ConstArgKind::Error(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Error",
&__self_0),
ConstArgKind::Infer(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
&__self_0),
ConstArgKind::Literal { lit: __self_0, negated: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"Literal", "lit", __self_0, "negated", &__self_1),
}
}
}Debug, const _: () =
{
impl<'hir, Unambig> ::rustc_data_structures::stable_hash::StableHash
for ConstArgKind<'hir, Unambig> where
Unambig: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ConstArgKind::Tup(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ConstArgKind::Path(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ConstArgKind::Anon(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ConstArgKind::Struct(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ConstArgKind::TupleCall(ref __binding_0, ref __binding_1) =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ConstArgKind::Array(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ConstArgKind::Error(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ConstArgKind::Infer(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ConstArgKind::Literal {
lit: ref __binding_0, negated: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
512#[repr(u8, C)]
513pub enum ConstArgKind<'hir, Unambig = ()> {
514 Tup(&'hir [&'hir ConstArg<'hir, Unambig>]),
515 Path(QPath<'hir>),
521 Anon(&'hir AnonConst),
522 Struct(QPath<'hir>, &'hir [&'hir ConstArgExprField<'hir>]),
524 TupleCall(QPath<'hir>, &'hir [&'hir ConstArg<'hir>]),
526 Array(&'hir ConstArgArrayExpr<'hir>),
528 Error(ErrorGuaranteed),
530 Infer(Unambig),
533 Literal {
534 lit: LitKind,
535 negated: bool,
536 },
537}
538
539#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for ConstArgExprField<'hir> {
#[inline]
fn clone(&self) -> ConstArgExprField<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ConstArgExprField<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for ConstArgExprField<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"ConstArgExprField", "hir_id", &self.hir_id, "span", &self.span,
"field", &self.field, "expr", &&self.expr)
}
}Debug, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ConstArgExprField<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ConstArgExprField {
hir_id: ref __binding_0,
span: ref __binding_1,
field: ref __binding_2,
expr: ref __binding_3 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
540pub struct ConstArgExprField<'hir> {
541 pub hir_id: HirId,
542 pub span: Span,
543 pub field: Ident,
544 pub expr: &'hir ConstArg<'hir>,
545}
546
547#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for ConstArgArrayExpr<'hir> {
#[inline]
fn clone(&self) -> ConstArgArrayExpr<'hir> {
let _: ::core::clone::AssertParamIsClone<Span>;
let _:
::core::clone::AssertParamIsClone<&'hir [&'hir ConstArg<'hir>]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ConstArgArrayExpr<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for ConstArgArrayExpr<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"ConstArgArrayExpr", "span", &self.span, "elems", &&self.elems)
}
}Debug, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ConstArgArrayExpr<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ConstArgArrayExpr {
span: ref __binding_0, elems: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
548pub struct ConstArgArrayExpr<'hir> {
549 pub span: Span,
550 pub elems: &'hir [&'hir ConstArg<'hir>],
551}
552
553#[derive(#[automatically_derived]
impl ::core::clone::Clone for InferArg {
#[inline]
fn clone(&self) -> InferArg {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InferArg { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for InferArg {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "InferArg",
"hir_id", &self.hir_id, "span", &&self.span)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for InferArg {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
InferArg { hir_id: ref __binding_0, span: ref __binding_1 }
=> {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
554pub struct InferArg {
555 #[stable_hash(ignore)]
556 pub hir_id: HirId,
557 pub span: Span,
558}
559
560impl InferArg {
561 pub fn to_ty(&self) -> Ty<'static> {
562 Ty { kind: TyKind::Infer(()), span: self.span, hir_id: self.hir_id }
563 }
564}
565
566#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericArg<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
GenericArg::Lifetime(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Lifetime", &__self_0),
GenericArg::Type(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Type",
&__self_0),
GenericArg::Const(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
&__self_0),
GenericArg::Infer(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericArg<'hir> {
#[inline]
fn clone(&self) -> GenericArg<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir, AmbigArg>>;
let _:
::core::clone::AssertParamIsClone<&'hir ConstArg<'hir,
AmbigArg>>;
let _: ::core::clone::AssertParamIsClone<InferArg>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericArg<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
GenericArg<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
GenericArg::Lifetime(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
GenericArg::Type(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
GenericArg::Const(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
GenericArg::Infer(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
567pub enum GenericArg<'hir> {
568 Lifetime(&'hir Lifetime),
569 Type(&'hir Ty<'hir, AmbigArg>),
570 Const(&'hir ConstArg<'hir, AmbigArg>),
571 Infer(InferArg),
581}
582
583impl GenericArg<'_> {
584 pub fn span(&self) -> Span {
585 match self {
586 GenericArg::Lifetime(l) => l.ident.span,
587 GenericArg::Type(t) => t.span,
588 GenericArg::Const(c) => c.span,
589 GenericArg::Infer(i) => i.span,
590 }
591 }
592
593 pub fn hir_id(&self) -> HirId {
594 match self {
595 GenericArg::Lifetime(l) => l.hir_id,
596 GenericArg::Type(t) => t.hir_id,
597 GenericArg::Const(c) => c.hir_id,
598 GenericArg::Infer(i) => i.hir_id,
599 }
600 }
601
602 pub fn descr(&self) -> &'static str {
603 match self {
604 GenericArg::Lifetime(_) => "lifetime",
605 GenericArg::Type(_) => "type",
606 GenericArg::Const(_) => "constant",
607 GenericArg::Infer(_) => "placeholder",
608 }
609 }
610
611 pub fn to_ord(&self) -> ast::ParamKindOrd {
612 match self {
613 GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime,
614 GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => {
615 ast::ParamKindOrd::TypeOrConst
616 }
617 }
618 }
619
620 pub fn is_ty_or_const(&self) -> bool {
621 match self {
622 GenericArg::Lifetime(_) => false,
623 GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => true,
624 }
625 }
626}
627
628#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericArgs<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "GenericArgs",
"args", &self.args, "constraints", &self.constraints,
"parenthesized", &self.parenthesized, "span_ext", &&self.span_ext)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericArgs<'hir> {
#[inline]
fn clone(&self) -> GenericArgs<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [GenericArg<'hir>]>;
let _:
::core::clone::AssertParamIsClone<&'hir [AssocItemConstraint<'hir>]>;
let _: ::core::clone::AssertParamIsClone<GenericArgsParentheses>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericArgs<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
GenericArgs<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
GenericArgs {
args: ref __binding_0,
constraints: ref __binding_1,
parenthesized: ref __binding_2,
span_ext: ref __binding_3 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
630pub struct GenericArgs<'hir> {
631 pub args: &'hir [GenericArg<'hir>],
633 pub constraints: &'hir [AssocItemConstraint<'hir>],
635 pub parenthesized: GenericArgsParentheses,
640 pub span_ext: Span,
653}
654
655impl<'hir> GenericArgs<'hir> {
656 pub const NONE: &'hir GenericArgs<'hir> = &GenericArgs {
657 args: &[],
658 constraints: &[],
659 parenthesized: GenericArgsParentheses::No,
660 span_ext: DUMMY_SP,
661 };
662
663 pub fn paren_sugar_inputs_output(&self) -> Option<(&[Ty<'hir>], &Ty<'hir>)> {
668 if self.parenthesized != GenericArgsParentheses::ParenSugar {
669 return None;
670 }
671
672 let inputs = self
673 .args
674 .iter()
675 .find_map(|arg| {
676 let GenericArg::Type(ty) = arg else { return None };
677 let TyKind::Tup(tys) = &ty.kind else { return None };
678 Some(tys)
679 })
680 .unwrap();
681
682 Some((inputs, self.paren_sugar_output_inner()))
683 }
684
685 pub fn paren_sugar_output(&self) -> Option<&Ty<'hir>> {
690 (self.parenthesized == GenericArgsParentheses::ParenSugar)
691 .then(|| self.paren_sugar_output_inner())
692 }
693
694 fn paren_sugar_output_inner(&self) -> &Ty<'hir> {
695 let [constraint] = self.constraints.try_into().unwrap();
696 if true {
{
match (&constraint.ident.name, &sym::Output) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};
};debug_assert_eq!(constraint.ident.name, sym::Output);
697 constraint.ty().unwrap()
698 }
699
700 pub fn has_err(&self) -> Option<ErrorGuaranteed> {
701 self.args
702 .iter()
703 .find_map(|arg| {
704 let GenericArg::Type(ty) = arg else { return None };
705 let TyKind::Err(guar) = ty.kind else { return None };
706 Some(guar)
707 })
708 .or_else(|| {
709 self.constraints.iter().find_map(|constraint| {
710 let TyKind::Err(guar) = constraint.ty()?.kind else { return None };
711 Some(guar)
712 })
713 })
714 }
715
716 #[inline]
717 pub fn num_lifetime_args(&self) -> usize {
718 self.args.iter().filter(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
719 }
720
721 #[inline]
722 pub fn has_lifetime_args(&self) -> bool {
723 self.args.iter().any(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_)))
724 }
725
726 #[inline]
727 pub fn num_generic_params(&self) -> usize {
730 self.args.iter().filter(|arg| !#[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
731 }
732
733 pub fn span(&self) -> Option<Span> {
739 let span_ext = self.span_ext()?;
740 Some(span_ext.with_lo(span_ext.lo() + BytePos(1)).with_hi(span_ext.hi() - BytePos(1)))
741 }
742
743 pub fn span_ext(&self) -> Option<Span> {
745 Some(self.span_ext).filter(|span| !span.is_empty())
746 }
747
748 pub fn is_empty(&self) -> bool {
749 self.args.is_empty()
750 }
751}
752
753#[derive(#[automatically_derived]
impl ::core::marker::Copy for GenericArgsParentheses { }Copy, #[automatically_derived]
impl ::core::clone::Clone for GenericArgsParentheses {
#[inline]
fn clone(&self) -> GenericArgsParentheses { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for GenericArgsParentheses {
#[inline]
fn eq(&self, other: &GenericArgsParentheses) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for GenericArgsParentheses {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for GenericArgsParentheses {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
GenericArgsParentheses::No => "No",
GenericArgsParentheses::ReturnTypeNotation =>
"ReturnTypeNotation",
GenericArgsParentheses::ParenSugar => "ParenSugar",
})
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
GenericArgsParentheses {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
GenericArgsParentheses::No => {}
GenericArgsParentheses::ReturnTypeNotation => {}
GenericArgsParentheses::ParenSugar => {}
}
}
}
};StableHash)]
754pub enum GenericArgsParentheses {
755 No,
756 ReturnTypeNotation,
759 ParenSugar,
761}
762
763#[derive(#[automatically_derived]
impl ::core::marker::Copy for TraitBoundModifiers { }Copy, #[automatically_derived]
impl ::core::clone::Clone for TraitBoundModifiers {
#[inline]
fn clone(&self) -> TraitBoundModifiers {
let _: ::core::clone::AssertParamIsClone<BoundConstness>;
let _: ::core::clone::AssertParamIsClone<BoundPolarity>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for TraitBoundModifiers {
#[inline]
fn eq(&self, other: &TraitBoundModifiers) -> bool {
self.constness == other.constness && self.polarity == other.polarity
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for TraitBoundModifiers {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<BoundConstness>;
let _: ::core::cmp::AssertParamIsEq<BoundPolarity>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for TraitBoundModifiers {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.constness, state);
::core::hash::Hash::hash(&self.polarity, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for TraitBoundModifiers {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"TraitBoundModifiers", "constness", &self.constness, "polarity",
&&self.polarity)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
TraitBoundModifiers {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TraitBoundModifiers {
constness: ref __binding_0, polarity: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
765pub struct TraitBoundModifiers {
766 pub constness: BoundConstness,
767 pub polarity: BoundPolarity,
768}
769
770impl TraitBoundModifiers {
771 pub const NONE: Self =
772 TraitBoundModifiers { constness: BoundConstness::Never, polarity: BoundPolarity::Positive };
773}
774
775#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericBound<'hir> {
#[inline]
fn clone(&self) -> GenericBound<'hir> {
let _: ::core::clone::AssertParamIsClone<PolyTraitRef<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
let _:
::core::clone::AssertParamIsClone<&'hir [PreciseCapturingArg<'hir>]>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericBound<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericBound<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
GenericBound::Trait(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Trait",
&__self_0),
GenericBound::Outlives(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Outlives", &__self_0),
GenericBound::Use(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Use",
__self_0, &__self_1),
}
}
}Debug, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
GenericBound<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
GenericBound::Trait(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
GenericBound::Outlives(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
GenericBound::Use(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
776pub enum GenericBound<'hir> {
777 Trait(PolyTraitRef<'hir>),
778 Outlives(&'hir Lifetime),
779 Use(&'hir [PreciseCapturingArg<'hir>], Span),
780}
781
782impl GenericBound<'_> {
783 pub fn trait_ref(&self) -> Option<&TraitRef<'_>> {
784 match self {
785 GenericBound::Trait(data) => Some(&data.trait_ref),
786 _ => None,
787 }
788 }
789
790 pub fn span(&self) -> Span {
791 match self {
792 GenericBound::Trait(t, ..) => t.span,
793 GenericBound::Outlives(l) => l.ident.span,
794 GenericBound::Use(_, span) => *span,
795 }
796 }
797}
798
799pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>];
800
801#[derive(#[automatically_derived]
impl ::core::marker::Copy for MissingLifetimeKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for MissingLifetimeKind {
#[inline]
fn clone(&self) -> MissingLifetimeKind { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for MissingLifetimeKind {
#[inline]
fn eq(&self, other: &MissingLifetimeKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for MissingLifetimeKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for MissingLifetimeKind {
#[inline]
fn partial_cmp(&self, other: &MissingLifetimeKind)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for MissingLifetimeKind {
#[inline]
fn cmp(&self, other: &MissingLifetimeKind) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for MissingLifetimeKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
MissingLifetimeKind {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
MissingLifetimeKind::Underscore => {}
MissingLifetimeKind::Ampersand => {}
MissingLifetimeKind::Comma => {}
MissingLifetimeKind::Brackets => {}
}
}
}
};StableHash, #[automatically_derived]
impl ::core::fmt::Debug for MissingLifetimeKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
MissingLifetimeKind::Underscore => "Underscore",
MissingLifetimeKind::Ampersand => "Ampersand",
MissingLifetimeKind::Comma => "Comma",
MissingLifetimeKind::Brackets => "Brackets",
})
}
}Debug)]
802pub enum MissingLifetimeKind {
803 Underscore,
805 Ampersand,
807 Comma,
809 Brackets,
811}
812
813#[derive(#[automatically_derived]
impl ::core::marker::Copy for LifetimeParamKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeParamKind {
#[inline]
fn clone(&self) -> LifetimeParamKind {
let _: ::core::clone::AssertParamIsClone<MissingLifetimeKind>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for LifetimeParamKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
LifetimeParamKind::Explicit =>
::core::fmt::Formatter::write_str(f, "Explicit"),
LifetimeParamKind::Elided(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Elided",
&__self_0),
LifetimeParamKind::Error =>
::core::fmt::Formatter::write_str(f, "Error"),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
LifetimeParamKind {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
LifetimeParamKind::Explicit => {}
LifetimeParamKind::Elided(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
LifetimeParamKind::Error => {}
}
}
}
};StableHash)]
814pub enum LifetimeParamKind {
815 Explicit,
818
819 Elided(MissingLifetimeKind),
822
823 Error,
825}
826
827#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericParamKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
GenericParamKind::Lifetime { kind: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Lifetime", "kind", &__self_0),
GenericParamKind::Type { default: __self_0, synthetic: __self_1 }
=>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Type",
"default", __self_0, "synthetic", &__self_1),
GenericParamKind::Const { ty: __self_0, default: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Const",
"ty", __self_0, "default", &__self_1),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericParamKind<'hir> {
#[inline]
fn clone(&self) -> GenericParamKind<'hir> {
let _: ::core::clone::AssertParamIsClone<LifetimeParamKind>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _:
::core::clone::AssertParamIsClone<Option<&'hir ConstArg<'hir>>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericParamKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
GenericParamKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
GenericParamKind::Lifetime { kind: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
GenericParamKind::Type {
default: ref __binding_0, synthetic: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
GenericParamKind::Const {
ty: ref __binding_0, default: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
828pub enum GenericParamKind<'hir> {
829 Lifetime {
831 kind: LifetimeParamKind,
832 },
833 Type {
834 default: Option<&'hir Ty<'hir>>,
835 synthetic: bool,
836 },
837 Const {
838 ty: &'hir Ty<'hir>,
839 default: Option<&'hir ConstArg<'hir>>,
841 },
842}
843
844#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericParam<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["hir_id", "def_id", "name", "span", "pure_wrt_drop", "kind",
"colon_span", "source"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.hir_id, &self.def_id, &self.name, &self.span,
&self.pure_wrt_drop, &self.kind, &self.colon_span,
&&self.source];
::core::fmt::Formatter::debug_struct_fields_finish(f, "GenericParam",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericParam<'hir> {
#[inline]
fn clone(&self) -> GenericParam<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<ParamName>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<GenericParamKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<Span>>;
let _: ::core::clone::AssertParamIsClone<GenericParamSource>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericParam<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
GenericParam<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
GenericParam {
hir_id: ref __binding_0,
def_id: ref __binding_1,
name: ref __binding_2,
span: ref __binding_3,
pure_wrt_drop: ref __binding_4,
kind: ref __binding_5,
colon_span: ref __binding_6,
source: ref __binding_7 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
{ __binding_6.stable_hash(__hcx, __hasher); }
{ __binding_7.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
845pub struct GenericParam<'hir> {
846 #[stable_hash(ignore)]
847 pub hir_id: HirId,
848 pub def_id: LocalDefId,
849 pub name: ParamName,
850 pub span: Span,
851 pub pure_wrt_drop: bool,
852 pub kind: GenericParamKind<'hir>,
853 pub colon_span: Option<Span>,
854 pub source: GenericParamSource,
855}
856
857impl<'hir> GenericParam<'hir> {
858 pub fn is_impl_trait(&self) -> bool {
862 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Type { synthetic: true, .. } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Type { synthetic: true, .. })
863 }
864
865 pub fn is_elided_lifetime(&self) -> bool {
869 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) })
870 }
871
872 pub fn is_lifetime(&self) -> bool {
873 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Lifetime { .. } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Lifetime { .. })
874 }
875}
876
877#[derive(#[automatically_derived]
impl ::core::fmt::Debug for GenericParamSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
GenericParamSource::Generics => "Generics",
GenericParamSource::Binder => "Binder",
})
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for GenericParamSource {
#[inline]
fn clone(&self) -> GenericParamSource { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for GenericParamSource { }Copy, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
GenericParamSource {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
GenericParamSource::Generics => {}
GenericParamSource::Binder => {}
}
}
}
};StableHash)]
884pub enum GenericParamSource {
885 Generics,
887 Binder,
889}
890
891#[derive(#[automatically_derived]
impl ::core::default::Default for GenericParamCount {
#[inline]
fn default() -> GenericParamCount {
GenericParamCount {
lifetimes: ::core::default::Default::default(),
types: ::core::default::Default::default(),
consts: ::core::default::Default::default(),
infer: ::core::default::Default::default(),
}
}
}Default)]
892pub struct GenericParamCount {
893 pub lifetimes: usize,
894 pub types: usize,
895 pub consts: usize,
896 pub infer: usize,
897}
898
899#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Generics<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Generics",
"params", &self.params, "predicates", &self.predicates,
"has_where_clause_predicates", &self.has_where_clause_predicates,
"where_clause_span", &self.where_clause_span, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Generics<'hir> {
#[inline]
fn clone(&self) -> Generics<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _:
::core::clone::AssertParamIsClone<&'hir [WherePredicate<'hir>]>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Generics<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Generics<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Generics {
params: ref __binding_0,
predicates: ref __binding_1,
has_where_clause_predicates: ref __binding_2,
where_clause_span: ref __binding_3,
span: ref __binding_4 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
902pub struct Generics<'hir> {
903 pub params: &'hir [GenericParam<'hir>],
904 pub predicates: &'hir [WherePredicate<'hir>],
905 pub has_where_clause_predicates: bool,
906 pub where_clause_span: Span,
907 pub span: Span,
908}
909
910impl<'hir> Generics<'hir> {
911 pub const fn empty() -> &'hir Generics<'hir> {
912 const NOPE: Generics<'_> = Generics {
913 params: &[],
914 predicates: &[],
915 has_where_clause_predicates: false,
916 where_clause_span: DUMMY_SP,
917 span: DUMMY_SP,
918 };
919 &NOPE
920 }
921
922 pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'hir>> {
923 self.params.iter().find(|¶m| name == param.name.ident().name)
924 }
925
926 pub fn span_for_lifetime_suggestion(&self) -> Option<Span> {
928 if let Some(first) = self.params.first()
929 && self.span.contains(first.span)
930 {
931 Some(first.span.shrink_to_lo())
934 } else {
935 None
936 }
937 }
938
939 pub fn span_for_param_suggestion(&self) -> Option<Span> {
941 self.params.iter().any(|p| self.span.contains(p.span)).then(|| {
942 self.span.with_lo(self.span.hi() - BytePos(1)).shrink_to_lo()
945 })
946 }
947
948 pub fn tail_span_for_predicate_suggestion(&self) -> Span {
951 let end = self.where_clause_span.shrink_to_hi();
952 if self.has_where_clause_predicates {
953 self.predicates
954 .iter()
955 .rfind(|&p| p.kind.in_where_clause())
956 .map_or(end, |p| p.span)
957 .shrink_to_hi()
958 .to(end)
959 } else {
960 end
961 }
962 }
963
964 pub fn add_where_or_trailing_comma(&self) -> &'static str {
965 if self.has_where_clause_predicates {
966 ","
967 } else if self.where_clause_span.is_empty() {
968 " where"
969 } else {
970 ""
972 }
973 }
974
975 pub fn bounds_for_param(
976 &self,
977 param_def_id: LocalDefId,
978 ) -> impl Iterator<Item = &WhereBoundPredicate<'hir>> {
979 self.predicates.iter().filter_map(move |pred| match pred.kind {
980 WherePredicateKind::BoundPredicate(bp)
981 if bp.is_param_bound(param_def_id.to_def_id()) =>
982 {
983 Some(bp)
984 }
985 _ => None,
986 })
987 }
988
989 pub fn outlives_for_param(
990 &self,
991 param_def_id: LocalDefId,
992 ) -> impl Iterator<Item = &WhereRegionPredicate<'_>> {
993 self.predicates.iter().filter_map(move |pred| match pred.kind {
994 WherePredicateKind::RegionPredicate(rp) if rp.is_param_bound(param_def_id) => Some(rp),
995 _ => None,
996 })
997 }
998
999 pub fn bounds_span_for_suggestions(
1010 &self,
1011 param_def_id: LocalDefId,
1012 ) -> Option<(Span, Option<Span>)> {
1013 self.bounds_for_param(param_def_id).flat_map(|bp| bp.bounds.iter().rev()).find_map(
1014 |bound| {
1015 let span_for_parentheses = if let Some(trait_ref) = bound.trait_ref()
1016 && let [.., segment] = trait_ref.path.segments
1017 && let Some(ret_ty) = segment.args().paren_sugar_output()
1018 && let ret_ty = ret_ty.peel_refs()
1019 && let TyKind::TraitObject(_, tagged_ptr) = ret_ty.kind
1020 && let TraitObjectSyntax::Dyn = tagged_ptr.tag()
1021 && ret_ty.span.can_be_used_for_suggestions()
1022 {
1023 Some(ret_ty.span)
1024 } else {
1025 None
1026 };
1027
1028 span_for_parentheses.map_or_else(
1029 || {
1030 let bs = bound.span();
1033 bs.from_expansion().not().then(|| (bs.shrink_to_hi(), None))
1038 },
1039 |span| Some((span.shrink_to_hi(), Some(span.shrink_to_lo()))),
1040 )
1041 },
1042 )
1043 }
1044
1045 pub fn span_for_predicate_removal(&self, pos: usize) -> Span {
1046 let predicate = &self.predicates[pos];
1047 let span = predicate.span;
1048
1049 if !predicate.kind.in_where_clause() {
1050 return span;
1053 }
1054
1055 if pos < self.predicates.len() - 1 {
1057 let next_pred = &self.predicates[pos + 1];
1058 if next_pred.kind.in_where_clause() {
1059 return span.until(next_pred.span);
1062 }
1063 }
1064
1065 if pos > 0 {
1066 let prev_pred = &self.predicates[pos - 1];
1067 if prev_pred.kind.in_where_clause() {
1068 return prev_pred.span.shrink_to_hi().to(span);
1071 }
1072 }
1073
1074 self.where_clause_span
1078 }
1079
1080 pub fn span_for_bound_removal(&self, predicate_pos: usize, bound_pos: usize) -> Span {
1081 let predicate = &self.predicates[predicate_pos];
1082 let bounds = predicate.kind.bounds();
1083
1084 if bounds.len() == 1 {
1085 return self.span_for_predicate_removal(predicate_pos);
1086 }
1087
1088 let bound_span = bounds[bound_pos].span();
1089 if bound_pos < bounds.len() - 1 {
1090 bound_span.to(bounds[bound_pos + 1].span().shrink_to_lo())
1096 } else {
1097 bound_span.with_lo(bounds[bound_pos - 1].span().hi())
1103 }
1104 }
1105
1106 pub fn span_for_param_removal(&self, param_index: usize) -> Span {
1129 if param_index >= self.params.len() {
1130 return self.span.shrink_to_hi();
1131 }
1132
1133 let is_param_explicit = |par: &&GenericParam<'_>| match par.kind {
1134 GenericParamKind::Type { .. }
1135 | GenericParamKind::Const { .. }
1136 | GenericParamKind::Lifetime { kind: LifetimeParamKind::Explicit } => true,
1137 _ => false,
1138 };
1139
1140 if let Some(next) = self.params[param_index + 1..].iter().find(is_param_explicit) {
1142 self.params[param_index].span.until(next.span)
1143 } else if let Some(prev) = self.params[..param_index].iter().rfind(is_param_explicit) {
1144 let mut prev_span = prev.span;
1145 if let Some(prev_bounds_span) = self.span_for_param_bounds(prev) {
1147 prev_span = prev_span.to(prev_bounds_span);
1148 }
1149
1150 prev_span.shrink_to_hi().to(
1152 if let Some(cur_bounds_span) = self.span_for_param_bounds(&self.params[param_index])
1153 {
1154 cur_bounds_span
1155 } else {
1156 self.params[param_index].span
1157 },
1158 )
1159 } else {
1160 self.span
1162 }
1163 }
1164
1165 fn span_for_param_bounds(&self, param: &GenericParam<'hir>) -> Option<Span> {
1176 self.predicates
1177 .iter()
1178 .find(|pred| {
1179 if let WherePredicateKind::BoundPredicate(WhereBoundPredicate {
1180 origin: PredicateOrigin::GenericParam,
1181 bounded_ty,
1182 ..
1183 }) = pred.kind
1184 {
1185 bounded_ty.span == param.span
1186 } else {
1187 false
1188 }
1189 })
1190 .map(|pred| pred.span)
1191 }
1192}
1193
1194#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WherePredicate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"WherePredicate", "hir_id", &self.hir_id, "span", &self.span,
"kind", &&self.kind)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WherePredicate<'hir> {
#[inline]
fn clone(&self) -> WherePredicate<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _:
::core::clone::AssertParamIsClone<&'hir WherePredicateKind<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WherePredicate<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
WherePredicate<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
WherePredicate {
hir_id: ref __binding_0,
span: ref __binding_1,
kind: ref __binding_2 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1196pub struct WherePredicate<'hir> {
1197 #[stable_hash(ignore)]
1198 pub hir_id: HirId,
1199 pub span: Span,
1200 pub kind: &'hir WherePredicateKind<'hir>,
1201}
1202
1203#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WherePredicateKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
WherePredicateKind::BoundPredicate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"BoundPredicate", &__self_0),
WherePredicateKind::RegionPredicate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"RegionPredicate", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WherePredicateKind<'hir> {
#[inline]
fn clone(&self) -> WherePredicateKind<'hir> {
let _: ::core::clone::AssertParamIsClone<WhereBoundPredicate<'hir>>;
let _: ::core::clone::AssertParamIsClone<WhereRegionPredicate<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WherePredicateKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
WherePredicateKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
WherePredicateKind::BoundPredicate(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
WherePredicateKind::RegionPredicate(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1205pub enum WherePredicateKind<'hir> {
1206 BoundPredicate(WhereBoundPredicate<'hir>),
1208 RegionPredicate(WhereRegionPredicate<'hir>),
1210}
1211
1212impl<'hir> WherePredicateKind<'hir> {
1213 pub fn in_where_clause(&self) -> bool {
1214 match self {
1215 WherePredicateKind::BoundPredicate(p) => p.origin == PredicateOrigin::WhereClause,
1216 WherePredicateKind::RegionPredicate(p) => p.in_where_clause,
1217 }
1218 }
1219
1220 pub fn bounds(&self) -> GenericBounds<'hir> {
1221 match self {
1222 WherePredicateKind::BoundPredicate(p) => p.bounds,
1223 WherePredicateKind::RegionPredicate(p) => p.bounds,
1224 }
1225 }
1226}
1227
1228#[derive(#[automatically_derived]
impl ::core::marker::Copy for PredicateOrigin { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PredicateOrigin {
#[inline]
fn clone(&self) -> PredicateOrigin { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for PredicateOrigin {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
PredicateOrigin::WhereClause => "WhereClause",
PredicateOrigin::GenericParam => "GenericParam",
PredicateOrigin::ImplTrait => "ImplTrait",
})
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
PredicateOrigin {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
PredicateOrigin::WhereClause => {}
PredicateOrigin::GenericParam => {}
PredicateOrigin::ImplTrait => {}
}
}
}
};StableHash, #[automatically_derived]
impl ::core::cmp::PartialEq for PredicateOrigin {
#[inline]
fn eq(&self, other: &PredicateOrigin) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for PredicateOrigin {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq)]
1229pub enum PredicateOrigin {
1230 WhereClause,
1231 GenericParam,
1232 ImplTrait,
1233}
1234
1235#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WhereBoundPredicate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"WhereBoundPredicate", "origin", &self.origin,
"bound_generic_params", &self.bound_generic_params, "bounded_ty",
&self.bounded_ty, "bounds", &&self.bounds)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WhereBoundPredicate<'hir> {
#[inline]
fn clone(&self) -> WhereBoundPredicate<'hir> {
let _: ::core::clone::AssertParamIsClone<PredicateOrigin>;
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WhereBoundPredicate<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
WhereBoundPredicate<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
WhereBoundPredicate {
origin: ref __binding_0,
bound_generic_params: ref __binding_1,
bounded_ty: ref __binding_2,
bounds: ref __binding_3 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1237pub struct WhereBoundPredicate<'hir> {
1238 pub origin: PredicateOrigin,
1240 pub bound_generic_params: &'hir [GenericParam<'hir>],
1242 pub bounded_ty: &'hir Ty<'hir>,
1244 pub bounds: GenericBounds<'hir>,
1246}
1247
1248impl<'hir> WhereBoundPredicate<'hir> {
1249 pub fn is_param_bound(&self, param_def_id: DefId) -> bool {
1251 self.bounded_ty.as_generic_param().is_some_and(|(def_id, _)| def_id == param_def_id)
1252 }
1253}
1254
1255#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WhereRegionPredicate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"WhereRegionPredicate", "in_where_clause", &self.in_where_clause,
"lifetime", &self.lifetime, "bounds", &&self.bounds)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WhereRegionPredicate<'hir> {
#[inline]
fn clone(&self) -> WhereRegionPredicate<'hir> {
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WhereRegionPredicate<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
WhereRegionPredicate<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
WhereRegionPredicate {
in_where_clause: ref __binding_0,
lifetime: ref __binding_1,
bounds: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1257pub struct WhereRegionPredicate<'hir> {
1258 pub in_where_clause: bool,
1259 pub lifetime: &'hir Lifetime,
1260 pub bounds: GenericBounds<'hir>,
1261}
1262
1263impl<'hir> WhereRegionPredicate<'hir> {
1264 fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
1266 self.lifetime.kind == LifetimeKind::Param(param_def_id)
1267 }
1268}
1269
1270#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WhereEqPredicate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"WhereEqPredicate", "lhs_ty", &self.lhs_ty, "rhs_ty",
&&self.rhs_ty)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WhereEqPredicate<'hir> {
#[inline]
fn clone(&self) -> WhereEqPredicate<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WhereEqPredicate<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
WhereEqPredicate<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
WhereEqPredicate {
lhs_ty: ref __binding_0, rhs_ty: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1272pub struct WhereEqPredicate<'hir> {
1273 pub lhs_ty: &'hir Ty<'hir>,
1274 pub rhs_ty: &'hir Ty<'hir>,
1275}
1276
1277#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for ParentedNode<'tcx> {
#[inline]
fn clone(&self) -> ParentedNode<'tcx> {
let _: ::core::clone::AssertParamIsClone<ItemLocalId>;
let _: ::core::clone::AssertParamIsClone<Node<'tcx>>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for ParentedNode<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for ParentedNode<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "ParentedNode",
"parent", &self.parent, "node", &&self.node)
}
}Debug)]
1281pub struct ParentedNode<'tcx> {
1282 pub parent: ItemLocalId,
1283 pub node: Node<'tcx>,
1284}
1285
1286#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttrArgs {
#[inline]
fn clone(&self) -> AttrArgs {
match self {
AttrArgs::Empty => AttrArgs::Empty,
AttrArgs::Delimited(__self_0) =>
AttrArgs::Delimited(::core::clone::Clone::clone(__self_0)),
AttrArgs::Eq { eq_span: __self_0, expr: __self_1 } =>
AttrArgs::Eq {
eq_span: ::core::clone::Clone::clone(__self_0),
expr: ::core::clone::Clone::clone(__self_1),
},
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AttrArgs {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
AttrArgs::Empty => ::core::fmt::Formatter::write_str(f, "Empty"),
AttrArgs::Delimited(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Delimited", &__self_0),
AttrArgs::Eq { eq_span: __self_0, expr: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Eq",
"eq_span", __self_0, "expr", &__self_1),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for AttrArgs {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
AttrArgs::Empty => {}
AttrArgs::Delimited(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AttrArgs::Eq {
eq_span: ref __binding_0, expr: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for AttrArgs {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
AttrArgs::Empty => { 0usize }
AttrArgs::Delimited(ref __binding_0) => { 1usize }
AttrArgs::Eq {
eq_span: ref __binding_0, expr: ref __binding_1 } => {
2usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
AttrArgs::Empty => {}
AttrArgs::Delimited(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AttrArgs::Eq {
eq_span: ref __binding_0, expr: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for AttrArgs {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { AttrArgs::Empty }
1usize => {
AttrArgs::Delimited(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => {
AttrArgs::Eq {
eq_span: ::rustc_serialize::Decodable::decode(__decoder),
expr: ::rustc_serialize::Decodable::decode(__decoder),
}
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `AttrArgs`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
1288pub enum AttrArgs {
1289 Empty,
1291 Delimited(DelimArgs),
1293 Eq {
1295 eq_span: Span,
1297 expr: MetaItemLit,
1299 },
1300}
1301
1302#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttrPath {
#[inline]
fn clone(&self) -> AttrPath {
AttrPath {
segments: ::core::clone::Clone::clone(&self.segments),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AttrPath {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "AttrPath",
"segments", &self.segments, "span", &&self.span)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for AttrPath {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
AttrPath { segments: ref __binding_0, span: ref __binding_1
} => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for AttrPath {
fn encode(&self, __encoder: &mut __E) {
match *self {
AttrPath { segments: ref __binding_0, span: ref __binding_1
} => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for AttrPath {
fn decode(__decoder: &mut __D) -> Self {
AttrPath {
segments: ::rustc_serialize::Decodable::decode(__decoder),
span: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable)]
1303pub struct AttrPath {
1304 pub segments: Box<[Symbol]>,
1305 pub span: Span,
1306}
1307
1308impl IntoDiagArg for AttrPath {
1309 fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>) -> DiagArgValue {
1310 self.to_string().into_diag_arg(path)
1311 }
1312}
1313
1314impl AttrPath {
1315 pub fn from_ast(path: &ast::Path, lower_span: impl Copy + Fn(Span) -> Span) -> Self {
1316 AttrPath {
1317 segments: path
1318 .segments
1319 .iter()
1320 .map(|i| i.ident.name)
1321 .collect::<Vec<_>>()
1322 .into_boxed_slice(),
1323 span: lower_span(path.span),
1324 }
1325 }
1326}
1327
1328impl fmt::Display for AttrPath {
1329 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1330 f.write_fmt(format_args!("{0}",
join_path_idents(self.segments.iter().map(|i|
Ident { name: *i, span: DUMMY_SP }))))write!(
1331 f,
1332 "{}",
1333 join_path_idents(self.segments.iter().map(|i| Ident { name: *i, span: DUMMY_SP }))
1334 )
1335 }
1336}
1337
1338#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttrItem {
#[inline]
fn clone(&self) -> AttrItem {
AttrItem {
path: ::core::clone::Clone::clone(&self.path),
args: ::core::clone::Clone::clone(&self.args),
id: ::core::clone::Clone::clone(&self.id),
style: ::core::clone::Clone::clone(&self.style),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AttrItem {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "AttrItem",
"path", &self.path, "args", &self.args, "id", &self.id, "style",
&self.style, "span", &&self.span)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for AttrItem {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
AttrItem {
path: ref __binding_0,
args: ref __binding_1,
id: ref __binding_2,
style: ref __binding_3,
span: ref __binding_4 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for AttrItem {
fn encode(&self, __encoder: &mut __E) {
match *self {
AttrItem {
path: ref __binding_0,
args: ref __binding_1,
id: ref __binding_2,
style: ref __binding_3,
span: ref __binding_4 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_4,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for AttrItem {
fn decode(__decoder: &mut __D) -> Self {
AttrItem {
path: ::rustc_serialize::Decodable::decode(__decoder),
args: ::rustc_serialize::Decodable::decode(__decoder),
id: ::rustc_serialize::Decodable::decode(__decoder),
style: ::rustc_serialize::Decodable::decode(__decoder),
span: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable)]
1339pub struct AttrItem {
1340 pub path: AttrPath,
1342 pub args: AttrArgs,
1343 pub id: HashIgnoredAttrId,
1344 pub style: AttrStyle,
1347 pub span: Span,
1349}
1350
1351#[derive(#[automatically_derived]
impl ::core::marker::Copy for HashIgnoredAttrId { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for HashIgnoredAttrId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"HashIgnoredAttrId", "attr_id", &&self.attr_id)
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for HashIgnoredAttrId {
fn encode(&self, __encoder: &mut __E) {
match *self {
HashIgnoredAttrId { attr_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for HashIgnoredAttrId {
fn decode(__decoder: &mut __D) -> Self {
HashIgnoredAttrId {
attr_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::clone::Clone for HashIgnoredAttrId {
#[inline]
fn clone(&self) -> HashIgnoredAttrId {
let _: ::core::clone::AssertParamIsClone<AttrId>;
*self
}
}Clone)]
1354pub struct HashIgnoredAttrId {
1355 pub attr_id: AttrId,
1356}
1357
1358#[derive(#[automatically_derived]
impl ::core::clone::Clone for Attribute {
#[inline]
fn clone(&self) -> Attribute {
match self {
Attribute::Parsed(__self_0) =>
Attribute::Parsed(::core::clone::Clone::clone(__self_0)),
Attribute::Unparsed(__self_0) =>
Attribute::Unparsed(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Attribute {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Attribute::Parsed(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Parsed",
&__self_0),
Attribute::Unparsed(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Unparsed", &__self_0),
}
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Attribute {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Attribute::Parsed(ref __binding_0) => { 0usize }
Attribute::Unparsed(ref __binding_0) => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Attribute::Parsed(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
Attribute::Unparsed(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Attribute {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
Attribute::Parsed(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
Attribute::Unparsed(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Attribute`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Attribute {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
Attribute::Parsed(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Attribute::Unparsed(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1361pub enum Attribute {
1362 Parsed(AttributeKind),
1368
1369 Unparsed(Box<AttrItem>),
1372}
1373
1374impl Attribute {
1375 pub fn get_normal_item(&self) -> &AttrItem {
1376 match &self {
1377 Attribute::Unparsed(normal) => &normal,
1378 _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1379 }
1380 }
1381
1382 pub fn unwrap_normal_item(self) -> AttrItem {
1383 match self {
1384 Attribute::Unparsed(normal) => *normal,
1385 _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1386 }
1387 }
1388
1389 pub fn value_lit(&self) -> Option<&MetaItemLit> {
1390 match &self {
1391 Attribute::Unparsed(n) => match n.as_ref() {
1392 AttrItem { args: AttrArgs::Eq { eq_span: _, expr }, .. } => Some(expr),
1393 _ => None,
1394 },
1395 _ => None,
1396 }
1397 }
1398
1399 pub fn is_parsed_attr(&self) -> bool {
1400 match self {
1401 Attribute::Parsed(_) => true,
1402 Attribute::Unparsed(_) => false,
1403 }
1404 }
1405
1406 pub fn is_prefix_attr_for_suggestions(&self) -> bool {
1407 match self {
1408 Attribute::Unparsed(attr) => attr.span.desugaring_kind().is_none(),
1409 Attribute::Parsed(_) => true,
1412 }
1413 }
1414}
1415
1416impl AttributeExt for Attribute {
1417 #[inline]
1418 fn id(&self) -> AttrId {
1419 match &self {
1420 Attribute::Unparsed(u) => u.id.attr_id,
1421 _ => ::core::panicking::panic("explicit panic")panic!(),
1422 }
1423 }
1424
1425 #[inline]
1426 fn meta_item_list(&self) -> Option<ThinVec<ast::MetaItemInner>> {
1427 match &self {
1428 Attribute::Unparsed(n) => match n.as_ref() {
1429 AttrItem { args: AttrArgs::Delimited(d), .. } => {
1430 ast::MetaItemKind::list_from_tokens(d.tokens.clone())
1431 }
1432 _ => None,
1433 },
1434 _ => None,
1435 }
1436 }
1437
1438 #[inline]
1439 fn value_str(&self) -> Option<Symbol> {
1440 self.value_lit().and_then(|x| x.value_as_str())
1441 }
1442
1443 #[inline]
1444 fn value_span(&self) -> Option<Span> {
1445 self.value_lit().map(|i| i.span)
1446 }
1447
1448 #[inline]
1450 fn name(&self) -> Option<Symbol> {
1451 match &self {
1452 Attribute::Unparsed(n) => {
1453 if let [ident] = n.path.segments.as_ref() {
1454 Some(*ident)
1455 } else {
1456 None
1457 }
1458 }
1459 _ => None,
1460 }
1461 }
1462
1463 #[inline]
1464 fn path_matches(&self, name: &[Symbol]) -> bool {
1465 match &self {
1466 Attribute::Unparsed(n) => n.path.segments.iter().eq(name),
1467 _ => false,
1468 }
1469 }
1470
1471 #[inline]
1472 fn is_doc_comment(&self) -> Option<Span> {
1473 if let Attribute::Parsed(AttributeKind::DocComment { span, .. }) = self {
1474 Some(*span)
1475 } else {
1476 None
1477 }
1478 }
1479
1480 #[inline]
1481 fn span(&self) -> Span {
1482 match &self {
1483 Attribute::Unparsed(u) => u.span,
1484 Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
1486 Attribute::Parsed(AttributeKind::Deprecated { span, .. }) => *span,
1487 Attribute::Parsed(AttributeKind::CfgTrace(cfgs)) => cfgs[0].1,
1488 a => {
::core::panicking::panic_fmt(format_args!("can\'t get the span of an arbitrary parsed attribute: {0:?}",
a));
}panic!("can't get the span of an arbitrary parsed attribute: {a:?}"),
1489 }
1490 }
1491
1492 #[inline]
1493 fn is_word(&self) -> bool {
1494 match &self {
1495 Attribute::Unparsed(n) => {
1496 #[allow(non_exhaustive_omitted_patterns)] match n.args {
AttrArgs::Empty => true,
_ => false,
}matches!(n.args, AttrArgs::Empty)
1497 }
1498 _ => false,
1499 }
1500 }
1501
1502 #[inline]
1503 fn symbol_path(&self) -> Option<SmallVec<[Symbol; 1]>> {
1504 match &self {
1505 Attribute::Unparsed(n) => Some(n.path.segments.iter().copied().collect()),
1506 _ => None,
1507 }
1508 }
1509
1510 fn path_span(&self) -> Option<Span> {
1511 match &self {
1512 Attribute::Unparsed(attr) => Some(attr.path.span),
1513 Attribute::Parsed(_) => None,
1514 }
1515 }
1516
1517 #[inline]
1518 fn doc_str(&self) -> Option<Symbol> {
1519 match &self {
1520 Attribute::Parsed(AttributeKind::DocComment { comment, .. }) => Some(*comment),
1521 _ => None,
1522 }
1523 }
1524
1525 fn is_automatically_derived_attr(&self) -> bool {
1526 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::AutomaticallyDerived) => true,
_ => false,
}matches!(self, Attribute::Parsed(AttributeKind::AutomaticallyDerived))
1527 }
1528
1529 #[inline]
1530 fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1531 match &self {
1532 Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => {
1533 Some((*comment, *kind))
1534 }
1535 _ => None,
1536 }
1537 }
1538
1539 fn doc_resolution_scope(&self) -> Option<AttrStyle> {
1540 match self {
1541 Attribute::Parsed(AttributeKind::DocComment { style, .. }) => Some(*style),
1542 Attribute::Unparsed(attr) if self.has_name(sym::doc) && self.value_str().is_some() => {
1543 Some(attr.style)
1544 }
1545 _ => None,
1546 }
1547 }
1548
1549 fn is_proc_macro_attr(&self) -> bool {
1550 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::ProcMacro |
AttributeKind::ProcMacroAttribute | AttributeKind::ProcMacroDerive {
.. }) => true,
_ => false,
}matches!(
1551 self,
1552 Attribute::Parsed(
1553 AttributeKind::ProcMacro
1554 | AttributeKind::ProcMacroAttribute
1555 | AttributeKind::ProcMacroDerive { .. }
1556 )
1557 )
1558 }
1559
1560 fn is_doc_hidden(&self) -> bool {
1561 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::Doc(d)) if d.hidden.is_some() => true,
_ => false,
}matches!(self, Attribute::Parsed(AttributeKind::Doc(d)) if d.hidden.is_some())
1562 }
1563
1564 fn is_doc_keyword_or_attribute(&self) -> bool {
1565 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::Doc(d)) if
d.attribute.is_some() || d.keyword.is_some() => true,
_ => false,
}matches!(self, Attribute::Parsed(AttributeKind::Doc(d)) if d.attribute.is_some() || d.keyword.is_some())
1566 }
1567
1568 fn is_rustc_doc_primitive(&self) -> bool {
1569 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::RustcDocPrimitive(..)) => true,
_ => false,
}matches!(self, Attribute::Parsed(AttributeKind::RustcDocPrimitive(..)))
1570 }
1571}
1572
1573impl Attribute {
1575 #[inline]
1576 pub fn id(&self) -> AttrId {
1577 AttributeExt::id(self)
1578 }
1579
1580 #[inline]
1581 pub fn name(&self) -> Option<Symbol> {
1582 AttributeExt::name(self)
1583 }
1584
1585 #[inline]
1586 pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
1587 AttributeExt::meta_item_list(self)
1588 }
1589
1590 #[inline]
1591 pub fn value_str(&self) -> Option<Symbol> {
1592 AttributeExt::value_str(self)
1593 }
1594
1595 #[inline]
1596 pub fn value_span(&self) -> Option<Span> {
1597 AttributeExt::value_span(self)
1598 }
1599
1600 #[inline]
1601 pub fn path_matches(&self, name: &[Symbol]) -> bool {
1602 AttributeExt::path_matches(self, name)
1603 }
1604
1605 #[inline]
1606 pub fn is_doc_comment(&self) -> Option<Span> {
1607 AttributeExt::is_doc_comment(self)
1608 }
1609
1610 #[inline]
1611 pub fn has_name(&self, name: Symbol) -> bool {
1612 AttributeExt::has_name(self, name)
1613 }
1614
1615 #[inline]
1616 pub fn has_any_name(&self, names: &[Symbol]) -> bool {
1617 AttributeExt::has_any_name(self, names)
1618 }
1619
1620 #[inline]
1621 pub fn span(&self) -> Span {
1622 AttributeExt::span(self)
1623 }
1624
1625 #[inline]
1626 pub fn is_word(&self) -> bool {
1627 AttributeExt::is_word(self)
1628 }
1629
1630 #[inline]
1631 pub fn path(&self) -> SmallVec<[Symbol; 1]> {
1632 AttributeExt::path(self)
1633 }
1634
1635 #[inline]
1636 pub fn doc_str(&self) -> Option<Symbol> {
1637 AttributeExt::doc_str(self)
1638 }
1639
1640 #[inline]
1641 pub fn is_proc_macro_attr(&self) -> bool {
1642 AttributeExt::is_proc_macro_attr(self)
1643 }
1644
1645 #[inline]
1646 pub fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1647 AttributeExt::doc_str_and_fragment_kind(self)
1648 }
1649}
1650
1651#[derive(#[automatically_derived]
impl<'tcx> ::core::fmt::Debug for AttributeMap<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "AttributeMap",
"map", &self.map, "define_opaque", &self.define_opaque,
"opt_hash", &&self.opt_hash)
}
}Debug)]
1653pub struct AttributeMap<'tcx> {
1654 pub map: SortedMap<ItemLocalId, &'tcx [Attribute]>,
1655 pub define_opaque: Option<&'tcx [(Span, LocalDefId)]>,
1657 pub opt_hash: Option<Fingerprint>,
1659}
1660
1661impl<'tcx> AttributeMap<'tcx> {
1662 pub const EMPTY: &'static AttributeMap<'static> = &AttributeMap {
1663 map: SortedMap::new(),
1664 opt_hash: Some(Fingerprint::ZERO),
1665 define_opaque: None,
1666 };
1667
1668 #[inline]
1669 pub fn get(&self, id: ItemLocalId) -> &'tcx [Attribute] {
1670 self.map.get(&id).copied().unwrap_or(&[])
1671 }
1672}
1673
1674pub struct OwnerNodes<'tcx> {
1678 pub opt_hash: Option<Fingerprint>,
1681 pub nodes: IndexVec<ItemLocalId, ParentedNode<'tcx>>,
1686 pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>,
1688}
1689
1690impl<'tcx> OwnerNodes<'tcx> {
1691 pub fn node(&self) -> OwnerNode<'tcx> {
1692 self.nodes[ItemLocalId::ZERO].node.as_owner().unwrap()
1694 }
1695
1696 pub fn synthetic() -> OwnerNodes<'tcx> {
1698 OwnerNodes {
1699 opt_hash: Some(Fingerprint::ZERO),
1702 nodes: IndexVec::from_elem_n(
1703 ParentedNode { parent: ItemLocalId::INVALID, node: OwnerNode::Synthetic.into() },
1704 1,
1705 ),
1706 bodies: SortedMap::new(),
1707 }
1708 }
1709}
1710
1711impl fmt::Debug for OwnerNodes<'_> {
1712 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1713 f.debug_struct("OwnerNodes")
1714 .field("node", &self.nodes[ItemLocalId::ZERO])
1716 .field(
1717 "parents",
1718 &fmt::from_fn(|f| {
1719 f.debug_list()
1720 .entries(self.nodes.iter_enumerated().map(|(id, parented_node)| {
1721 fmt::from_fn(move |f| f.write_fmt(format_args!("({1:?}, {0:?})", parented_node.parent, id))write!(f, "({id:?}, {:?})", parented_node.parent))
1722 }))
1723 .finish()
1724 }),
1725 )
1726 .field("bodies", &self.bodies)
1727 .field("opt_hash", &self.opt_hash)
1728 .finish()
1729 }
1730}
1731
1732#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for OwnerInfo<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["nodes", "parenting", "attrs", "trait_map", "children",
"delayed_lints", "opt_hash"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.nodes, &self.parenting, &self.attrs, &self.trait_map,
&self.children, &self.delayed_lints, &&self.opt_hash];
::core::fmt::Formatter::debug_struct_fields_finish(f, "OwnerInfo",
names, values)
}
}Debug)]
1734pub struct OwnerInfo<'hir> {
1735 pub nodes: OwnerNodes<'hir>,
1737 pub parenting: LocalDefIdMap<ItemLocalId>,
1739 pub attrs: AttributeMap<'hir>,
1741 pub trait_map: ItemLocalMap<&'hir [TraitCandidate<'hir>]>,
1744 pub children: UnordMap<LocalDefId, MaybeOwner<'hir>>,
1746
1747 pub delayed_lints: Steal<DelayedLints>,
1753
1754 pub opt_hash: Option<Fingerprint>,
1756}
1757
1758impl<'tcx> OwnerInfo<'tcx> {
1759 #[inline]
1760 pub fn node(&self) -> OwnerNode<'tcx> {
1761 self.nodes.node()
1762 }
1763}
1764
1765#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for MaybeOwner<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for MaybeOwner<'tcx> {
#[inline]
fn clone(&self) -> MaybeOwner<'tcx> {
let _: ::core::clone::AssertParamIsClone<&'tcx OwnerInfo<'tcx>>;
let _: ::core::clone::AssertParamIsClone<HirId>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for MaybeOwner<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
MaybeOwner::Owner(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Owner",
&__self_0),
MaybeOwner::NonOwner(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"NonOwner", &__self_0),
}
}
}Debug, const _: () =
{
impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
MaybeOwner<'tcx> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
MaybeOwner::Owner(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
MaybeOwner::NonOwner(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1766pub enum MaybeOwner<'tcx> {
1767 Owner(&'tcx OwnerInfo<'tcx>),
1768 NonOwner(HirId),
1769}
1770
1771impl<'tcx> MaybeOwner<'tcx> {
1772 #[inline]
1773 pub fn as_owner(self) -> Option<&'tcx OwnerInfo<'tcx>> {
1774 match self {
1775 MaybeOwner::Owner(i) => Some(i),
1776 MaybeOwner::NonOwner(_) => None,
1777 }
1778 }
1779
1780 #[inline]
1781 pub fn unwrap(self) -> &'tcx OwnerInfo<'tcx> {
1782 self.as_owner().unwrap_or_else(|| { ::core::panicking::panic_fmt(format_args!("Not a HIR owner")); }panic!("Not a HIR owner"))
1783 }
1784}
1785
1786#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Closure<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["def_id", "binder", "constness", "capture_clause",
"bound_generic_params", "fn_decl", "body", "fn_decl_span",
"fn_arg_span", "kind", "explicit_captures"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.def_id, &self.binder, &self.constness,
&self.capture_clause, &self.bound_generic_params,
&self.fn_decl, &self.body, &self.fn_decl_span,
&self.fn_arg_span, &self.kind, &&self.explicit_captures];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Closure",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Closure<'hir> {
#[inline]
fn clone(&self) -> Closure<'hir> {
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<ClosureBinder>;
let _: ::core::clone::AssertParamIsClone<Constness>;
let _: ::core::clone::AssertParamIsClone<CaptureBy>;
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir FnDecl<'hir>>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Option<Span>>;
let _: ::core::clone::AssertParamIsClone<ClosureKind>;
let _: ::core::clone::AssertParamIsClone<&'hir [ExplicitCapture]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Closure<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Closure<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Closure {
def_id: ref __binding_0,
binder: ref __binding_1,
constness: ref __binding_2,
capture_clause: ref __binding_3,
bound_generic_params: ref __binding_4,
fn_decl: ref __binding_5,
body: ref __binding_6,
fn_decl_span: ref __binding_7,
fn_arg_span: ref __binding_8,
kind: ref __binding_9,
explicit_captures: ref __binding_10 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
{ __binding_6.stable_hash(__hcx, __hasher); }
{ __binding_7.stable_hash(__hcx, __hasher); }
{ __binding_8.stable_hash(__hcx, __hasher); }
{ __binding_9.stable_hash(__hcx, __hasher); }
{ __binding_10.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1787pub struct Closure<'hir> {
1788 pub def_id: LocalDefId,
1789 pub binder: ClosureBinder,
1790 pub constness: Constness,
1791 pub capture_clause: CaptureBy,
1792 pub bound_generic_params: &'hir [GenericParam<'hir>],
1793 pub fn_decl: &'hir FnDecl<'hir>,
1794 pub body: BodyId,
1795 pub fn_decl_span: Span,
1797 pub fn_arg_span: Option<Span>,
1799 pub kind: ClosureKind,
1800 pub explicit_captures: &'hir [ExplicitCapture],
1801}
1802
1803#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ExplicitCapture {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"ExplicitCapture", "var_hir_id", &&self.var_hir_id)
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for ExplicitCapture {
#[inline]
fn clone(&self) -> ExplicitCapture {
let _: ::core::clone::AssertParamIsClone<HirId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ExplicitCapture { }Copy, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
ExplicitCapture {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ExplicitCapture { var_hir_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1806pub struct ExplicitCapture {
1807 pub var_hir_id: HirId,
1808}
1809
1810#[derive(#[automatically_derived]
impl ::core::clone::Clone for ClosureKind {
#[inline]
fn clone(&self) -> ClosureKind {
let _: ::core::clone::AssertParamIsClone<CoroutineKind>;
let _: ::core::clone::AssertParamIsClone<CoroutineDesugaring>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ClosureKind {
#[inline]
fn eq(&self, other: &ClosureKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(ClosureKind::Coroutine(__self_0),
ClosureKind::Coroutine(__arg1_0)) => __self_0 == __arg1_0,
(ClosureKind::CoroutineClosure(__self_0),
ClosureKind::CoroutineClosure(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ClosureKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<CoroutineKind>;
let _: ::core::cmp::AssertParamIsEq<CoroutineDesugaring>;
}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for ClosureKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ClosureKind::Closure =>
::core::fmt::Formatter::write_str(f, "Closure"),
ClosureKind::Coroutine(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Coroutine", &__self_0),
ClosureKind::CoroutineClosure(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"CoroutineClosure", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for ClosureKind { }Copy, #[automatically_derived]
impl ::core::hash::Hash for ClosureKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
ClosureKind::Coroutine(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
ClosureKind::CoroutineClosure(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for ClosureKind
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ClosureKind::Closure => {}
ClosureKind::Coroutine(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ClosureKind::CoroutineClosure(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ClosureKind {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
ClosureKind::Closure => { 0usize }
ClosureKind::Coroutine(ref __binding_0) => { 1usize }
ClosureKind::CoroutineClosure(ref __binding_0) => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
ClosureKind::Closure => {}
ClosureKind::Coroutine(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
ClosureKind::CoroutineClosure(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ClosureKind {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { ClosureKind::Closure }
1usize => {
ClosureKind::Coroutine(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => {
ClosureKind::CoroutineClosure(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ClosureKind`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
1811pub enum ClosureKind {
1812 Closure,
1814 Coroutine(CoroutineKind),
1819 CoroutineClosure(CoroutineDesugaring),
1824}
1825
1826#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Block<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["stmts", "expr", "hir_id", "rules", "span",
"targeted_by_break"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.stmts, &self.expr, &self.hir_id, &self.rules, &self.span,
&&self.targeted_by_break];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Block", names,
values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Block<'hir> {
#[inline]
fn clone(&self) -> Block<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [Stmt<'hir>]>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<BlockCheckMode>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Block<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Block<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Block {
stmts: ref __binding_0,
expr: ref __binding_1,
hir_id: ref __binding_2,
rules: ref __binding_3,
span: ref __binding_4,
targeted_by_break: ref __binding_5 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{}
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1830pub struct Block<'hir> {
1831 pub stmts: &'hir [Stmt<'hir>],
1833 pub expr: Option<&'hir Expr<'hir>>,
1836 #[stable_hash(ignore)]
1837 pub hir_id: HirId,
1838 pub rules: BlockCheckMode,
1840 pub span: Span,
1842 pub targeted_by_break: bool,
1846}
1847
1848impl<'hir> Block<'hir> {
1849 pub fn innermost_block(&self) -> &Block<'hir> {
1850 let mut block = self;
1851 while let Some(Expr { kind: ExprKind::Block(inner_block, _), .. }) = block.expr {
1852 block = inner_block;
1853 }
1854 block
1855 }
1856}
1857
1858#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TyFieldPath {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "TyFieldPath",
"variant", &self.variant, "field", &&self.field)
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TyFieldPath {
#[inline]
fn clone(&self) -> TyFieldPath {
let _: ::core::clone::AssertParamIsClone<Option<Ident>>;
let _: ::core::clone::AssertParamIsClone<Ident>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TyFieldPath { }Copy, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for TyFieldPath
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TyFieldPath {
variant: ref __binding_0, field: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1859pub struct TyFieldPath {
1860 pub variant: Option<Ident>,
1861 pub field: Ident,
1862}
1863
1864#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TyPat<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "TyPat",
"hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TyPat<'hir> {
#[inline]
fn clone(&self) -> TyPat<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<TyPatKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TyPat<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
TyPat<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TyPat {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1865pub struct TyPat<'hir> {
1866 #[stable_hash(ignore)]
1867 pub hir_id: HirId,
1868 pub kind: TyPatKind<'hir>,
1869 pub span: Span,
1870}
1871
1872#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Pat<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "Pat", "hir_id",
&self.hir_id, "kind", &self.kind, "span", &self.span,
"default_binding_modes", &&self.default_binding_modes)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Pat<'hir> {
#[inline]
fn clone(&self) -> Pat<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<PatKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Pat<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Pat<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Pat {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2,
default_binding_modes: ref __binding_3 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1873pub struct Pat<'hir> {
1874 #[stable_hash(ignore)]
1875 pub hir_id: HirId,
1876 pub kind: PatKind<'hir>,
1877 pub span: Span,
1878 pub default_binding_modes: bool,
1881}
1882
1883impl<'hir> Pat<'hir> {
1884 fn walk_short_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) -> bool {
1885 if !it(self) {
1886 return false;
1887 }
1888
1889 use PatKind::*;
1890 match self.kind {
1891 Missing => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1892 Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => true,
1893 Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => {
1894 s.walk_short_(it)
1895 }
1896 Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
1897 TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().all(|p| p.walk_short_(it)),
1898 Slice(before, slice, after) => {
1899 before.iter().chain(slice).chain(after.iter()).all(|p| p.walk_short_(it))
1900 }
1901 }
1902 }
1903
1904 pub fn walk_short(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) -> bool {
1911 self.walk_short_(&mut it)
1912 }
1913
1914 fn walk_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) {
1915 if !it(self) {
1916 return;
1917 }
1918
1919 use PatKind::*;
1920 match self.kind {
1921 Missing | Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => {}
1922 Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_(it),
1923 Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
1924 TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
1925 Slice(before, slice, after) => {
1926 before.iter().chain(slice).chain(after.iter()).for_each(|p| p.walk_(it))
1927 }
1928 }
1929 }
1930
1931 pub fn walk(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) {
1935 self.walk_(&mut it)
1936 }
1937
1938 pub fn walk_always(&self, mut it: impl FnMut(&Pat<'_>)) {
1942 self.walk(|p| {
1943 it(p);
1944 true
1945 })
1946 }
1947
1948 pub fn is_never_pattern(&self) -> bool {
1950 let mut is_never_pattern = false;
1951 self.walk(|pat| match &pat.kind {
1952 PatKind::Never => {
1953 is_never_pattern = true;
1954 false
1955 }
1956 PatKind::Or(s) => {
1957 is_never_pattern = s.iter().all(|p| p.is_never_pattern());
1958 false
1959 }
1960 _ => true,
1961 });
1962 is_never_pattern
1963 }
1964
1965 pub fn is_guaranteed_to_constitute_read_for_never(&self) -> bool {
1974 match self.kind {
1975 PatKind::Wild => false,
1977
1978 PatKind::Guard(pat, _) => pat.is_guaranteed_to_constitute_read_for_never(),
1981
1982 PatKind::Or(subpats) => {
1991 subpats.iter().all(|pat| pat.is_guaranteed_to_constitute_read_for_never())
1992 }
1993
1994 PatKind::Never => true,
1996
1997 PatKind::Missing
2000 | PatKind::Binding(_, _, _, _)
2001 | PatKind::Struct(_, _, _)
2002 | PatKind::TupleStruct(_, _, _)
2003 | PatKind::Tuple(_, _)
2004 | PatKind::Box(_)
2005 | PatKind::Ref(_, _, _)
2006 | PatKind::Deref(_)
2007 | PatKind::Expr(_)
2008 | PatKind::Range(_, _, _)
2009 | PatKind::Slice(_, _, _)
2010 | PatKind::Err(_) => true,
2011 }
2012 }
2013}
2014
2015#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatField<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "PatField",
"hir_id", &self.hir_id, "ident", &self.ident, "pat", &self.pat,
"is_shorthand", &self.is_shorthand, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatField<'hir> {
#[inline]
fn clone(&self) -> PatField<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatField<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
PatField<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
PatField {
hir_id: ref __binding_0,
ident: ref __binding_1,
pat: ref __binding_2,
is_shorthand: ref __binding_3,
span: ref __binding_4 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2021pub struct PatField<'hir> {
2022 #[stable_hash(ignore)]
2023 pub hir_id: HirId,
2024 pub ident: Ident,
2026 pub pat: &'hir Pat<'hir>,
2028 pub is_shorthand: bool,
2029 pub span: Span,
2030}
2031
2032#[derive(#[automatically_derived]
impl ::core::marker::Copy for RangeEnd { }Copy, #[automatically_derived]
impl ::core::clone::Clone for RangeEnd {
#[inline]
fn clone(&self) -> RangeEnd { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for RangeEnd {
#[inline]
fn eq(&self, other: &RangeEnd) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for RangeEnd {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
RangeEnd::Included => "Included",
RangeEnd::Excluded => "Excluded",
})
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for RangeEnd {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
RangeEnd::Included => {}
RangeEnd::Excluded => {}
}
}
}
};StableHash, #[automatically_derived]
impl ::core::hash::Hash for RangeEnd {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::cmp::Eq for RangeEnd {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for RangeEnd {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
RangeEnd::Included => { 0usize }
RangeEnd::Excluded => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
RangeEnd::Included => {}
RangeEnd::Excluded => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for RangeEnd {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { RangeEnd::Included }
1usize => { RangeEnd::Excluded }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `RangeEnd`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
2033pub enum RangeEnd {
2034 Included,
2035 Excluded,
2036}
2037
2038impl fmt::Display for RangeEnd {
2039 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2040 f.write_str(match self {
2041 RangeEnd::Included => "..=",
2042 RangeEnd::Excluded => "..",
2043 })
2044 }
2045}
2046
2047#[derive(#[automatically_derived]
impl ::core::clone::Clone for DotDotPos {
#[inline]
fn clone(&self) -> DotDotPos {
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DotDotPos { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for DotDotPos {
#[inline]
fn eq(&self, other: &DotDotPos) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DotDotPos {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for DotDotPos {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}Hash, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for DotDotPos {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
DotDotPos(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2051pub struct DotDotPos(u32);
2052
2053impl DotDotPos {
2054 pub fn new(n: Option<usize>) -> Self {
2056 match n {
2057 Some(n) => {
2058 if !(n < u32::MAX as usize) {
::core::panicking::panic("assertion failed: n < u32::MAX as usize")
};assert!(n < u32::MAX as usize);
2059 Self(n as u32)
2060 }
2061 None => Self(u32::MAX),
2062 }
2063 }
2064
2065 pub fn as_opt_usize(&self) -> Option<usize> {
2066 if self.0 == u32::MAX { None } else { Some(self.0 as usize) }
2067 }
2068}
2069
2070impl fmt::Debug for DotDotPos {
2071 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2072 self.as_opt_usize().fmt(f)
2073 }
2074}
2075
2076#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatExpr<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "PatExpr",
"hir_id", &self.hir_id, "span", &self.span, "kind", &&self.kind)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatExpr<'hir> {
#[inline]
fn clone(&self) -> PatExpr<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<PatExprKind<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatExpr<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
PatExpr<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
PatExpr {
hir_id: ref __binding_0,
span: ref __binding_1,
kind: ref __binding_2 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2077pub struct PatExpr<'hir> {
2078 #[stable_hash(ignore)]
2079 pub hir_id: HirId,
2080 pub span: Span,
2081 pub kind: PatExprKind<'hir>,
2082}
2083
2084#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatExprKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
PatExprKind::Lit { lit: __self_0, negated: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Lit",
"lit", __self_0, "negated", &__self_1),
PatExprKind::Path(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatExprKind<'hir> {
#[inline]
fn clone(&self) -> PatExprKind<'hir> {
let _: ::core::clone::AssertParamIsClone<Lit>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatExprKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
PatExprKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
PatExprKind::Lit {
lit: ref __binding_0, negated: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
PatExprKind::Path(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2085pub enum PatExprKind<'hir> {
2086 Lit {
2087 lit: Lit,
2088 negated: bool,
2089 },
2090 Path(QPath<'hir>),
2092}
2093
2094#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TyPatKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TyPatKind::Range(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Range",
__self_0, &__self_1),
TyPatKind::NotNull =>
::core::fmt::Formatter::write_str(f, "NotNull"),
TyPatKind::Or(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Or",
&__self_0),
TyPatKind::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TyPatKind<'hir> {
#[inline]
fn clone(&self) -> TyPatKind<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [TyPat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TyPatKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
TyPatKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
TyPatKind::Range(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyPatKind::NotNull => {}
TyPatKind::Or(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyPatKind::Err(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2095pub enum TyPatKind<'hir> {
2096 Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>),
2098
2099 NotNull,
2101
2102 Or(&'hir [TyPat<'hir>]),
2104
2105 Err(ErrorGuaranteed),
2107}
2108
2109#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
PatKind::Missing =>
::core::fmt::Formatter::write_str(f, "Missing"),
PatKind::Wild => ::core::fmt::Formatter::write_str(f, "Wild"),
PatKind::Binding(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f,
"Binding", __self_0, __self_1, __self_2, &__self_3),
PatKind::Struct(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Struct",
__self_0, __self_1, &__self_2),
PatKind::TupleStruct(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f,
"TupleStruct", __self_0, __self_1, &__self_2),
PatKind::Or(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Or",
&__self_0),
PatKind::Never => ::core::fmt::Formatter::write_str(f, "Never"),
PatKind::Tuple(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Tuple",
__self_0, &__self_1),
PatKind::Box(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Box",
&__self_0),
PatKind::Deref(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Deref",
&__self_0),
PatKind::Ref(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Ref",
__self_0, __self_1, &__self_2),
PatKind::Expr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Expr",
&__self_0),
PatKind::Guard(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Guard",
__self_0, &__self_1),
PatKind::Range(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Range",
__self_0, __self_1, &__self_2),
PatKind::Slice(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Slice",
__self_0, __self_1, &__self_2),
PatKind::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatKind<'hir> {
#[inline]
fn clone(&self) -> PatKind<'hir> {
let _: ::core::clone::AssertParamIsClone<BindingMode>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Pat<'hir>>>;
let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [PatField<'hir>]>;
let _: ::core::clone::AssertParamIsClone<Option<Span>>;
let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<DotDotPos>;
let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<Pinnedness>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
let _: ::core::clone::AssertParamIsClone<&'hir PatExpr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir PatExpr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir PatExpr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<RangeEnd>;
let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Pat<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
PatKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
PatKind::Missing => {}
PatKind::Wild => {}
PatKind::Binding(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
PatKind::Struct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
PatKind::TupleStruct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
PatKind::Or(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
PatKind::Never => {}
PatKind::Tuple(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
PatKind::Box(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
PatKind::Deref(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
PatKind::Ref(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
PatKind::Expr(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
PatKind::Guard(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
PatKind::Range(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
PatKind::Slice(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
PatKind::Err(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2110pub enum PatKind<'hir> {
2111 Missing,
2113
2114 Wild,
2116
2117 Binding(BindingMode, HirId, Ident, Option<&'hir Pat<'hir>>),
2128
2129 Struct(QPath<'hir>, &'hir [PatField<'hir>], Option<Span>),
2132
2133 TupleStruct(QPath<'hir>, &'hir [Pat<'hir>], DotDotPos),
2137
2138 Or(&'hir [Pat<'hir>]),
2141
2142 Never,
2144
2145 Tuple(&'hir [Pat<'hir>], DotDotPos),
2149
2150 Box(&'hir Pat<'hir>),
2152
2153 Deref(&'hir Pat<'hir>),
2155
2156 Ref(&'hir Pat<'hir>, Pinnedness, Mutability),
2158
2159 Expr(&'hir PatExpr<'hir>),
2161
2162 Guard(&'hir Pat<'hir>, &'hir Expr<'hir>),
2164
2165 Range(Option<&'hir PatExpr<'hir>>, Option<&'hir PatExpr<'hir>>, RangeEnd),
2167
2168 Slice(&'hir [Pat<'hir>], Option<&'hir Pat<'hir>>, &'hir [Pat<'hir>]),
2178
2179 Err(ErrorGuaranteed),
2181}
2182
2183#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Stmt<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "Stmt",
"hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Stmt<'hir> {
#[inline]
fn clone(&self) -> Stmt<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<StmtKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Stmt<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Stmt<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Stmt {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2185pub struct Stmt<'hir> {
2186 #[stable_hash(ignore)]
2187 pub hir_id: HirId,
2188 pub kind: StmtKind<'hir>,
2189 pub span: Span,
2190}
2191
2192#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for StmtKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
StmtKind::Let(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Let",
&__self_0),
StmtKind::Item(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Item",
&__self_0),
StmtKind::Expr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Expr",
&__self_0),
StmtKind::Semi(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Semi",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for StmtKind<'hir> {
#[inline]
fn clone(&self) -> StmtKind<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir LetStmt<'hir>>;
let _: ::core::clone::AssertParamIsClone<ItemId>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for StmtKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
StmtKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
StmtKind::Let(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
StmtKind::Item(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
StmtKind::Expr(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
StmtKind::Semi(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2194pub enum StmtKind<'hir> {
2195 Let(&'hir LetStmt<'hir>),
2197
2198 Item(ItemId),
2200
2201 Expr(&'hir Expr<'hir>),
2203
2204 Semi(&'hir Expr<'hir>),
2206}
2207
2208#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for LetStmt<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["super_", "pat", "ty", "init", "els", "hir_id", "span",
"source"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.super_, &self.pat, &self.ty, &self.init, &self.els,
&self.hir_id, &self.span, &&self.source];
::core::fmt::Formatter::debug_struct_fields_finish(f, "LetStmt",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for LetStmt<'hir> {
#[inline]
fn clone(&self) -> LetStmt<'hir> {
let _: ::core::clone::AssertParamIsClone<Option<Span>>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Block<'hir>>>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<LocalSource>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for LetStmt<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
LetStmt<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
LetStmt {
super_: ref __binding_0,
pat: ref __binding_1,
ty: ref __binding_2,
init: ref __binding_3,
els: ref __binding_4,
hir_id: ref __binding_5,
span: ref __binding_6,
source: ref __binding_7 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{}
{ __binding_6.stable_hash(__hcx, __hasher); }
{ __binding_7.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2210pub struct LetStmt<'hir> {
2211 pub super_: Option<Span>,
2213 pub pat: &'hir Pat<'hir>,
2214 pub ty: Option<&'hir Ty<'hir>>,
2216 pub init: Option<&'hir Expr<'hir>>,
2218 pub els: Option<&'hir Block<'hir>>,
2220 #[stable_hash(ignore)]
2221 pub hir_id: HirId,
2222 pub span: Span,
2223 pub source: LocalSource,
2227}
2228
2229#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Arm<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Arm", "hir_id",
&self.hir_id, "span", &self.span, "pat", &self.pat, "guard",
&self.guard, "body", &&self.body)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Arm<'hir> {
#[inline]
fn clone(&self) -> Arm<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Arm<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Arm<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Arm {
hir_id: ref __binding_0,
span: ref __binding_1,
pat: ref __binding_2,
guard: ref __binding_3,
body: ref __binding_4 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2232pub struct Arm<'hir> {
2233 #[stable_hash(ignore)]
2234 pub hir_id: HirId,
2235 pub span: Span,
2236 pub pat: &'hir Pat<'hir>,
2238 pub guard: Option<&'hir Expr<'hir>>,
2240 pub body: &'hir Expr<'hir>,
2242}
2243
2244#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for LetExpr<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "LetExpr",
"span", &self.span, "pat", &self.pat, "ty", &self.ty, "init",
&self.init, "recovered", &&self.recovered)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for LetExpr<'hir> {
#[inline]
fn clone(&self) -> LetExpr<'hir> {
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<ast::Recovered>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for LetExpr<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
LetExpr<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
LetExpr {
span: ref __binding_0,
pat: ref __binding_1,
ty: ref __binding_2,
init: ref __binding_3,
recovered: ref __binding_4 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2250pub struct LetExpr<'hir> {
2251 pub span: Span,
2252 pub pat: &'hir Pat<'hir>,
2253 pub ty: Option<&'hir Ty<'hir>>,
2254 pub init: &'hir Expr<'hir>,
2255 pub recovered: ast::Recovered,
2258}
2259
2260#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ExprField<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "ExprField",
"hir_id", &self.hir_id, "ident", &self.ident, "expr", &self.expr,
"span", &self.span, "is_shorthand", &&self.is_shorthand)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ExprField<'hir> {
#[inline]
fn clone(&self) -> ExprField<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ExprField<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ExprField<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ExprField {
hir_id: ref __binding_0,
ident: ref __binding_1,
expr: ref __binding_2,
span: ref __binding_3,
is_shorthand: ref __binding_4 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2261pub struct ExprField<'hir> {
2262 #[stable_hash(ignore)]
2263 pub hir_id: HirId,
2264 pub ident: Ident,
2265 pub expr: &'hir Expr<'hir>,
2266 pub span: Span,
2267 pub is_shorthand: bool,
2268}
2269
2270#[derive(#[automatically_derived]
impl ::core::marker::Copy for BlockCheckMode { }Copy, #[automatically_derived]
impl ::core::clone::Clone for BlockCheckMode {
#[inline]
fn clone(&self) -> BlockCheckMode {
let _: ::core::clone::AssertParamIsClone<UnsafeSource>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for BlockCheckMode {
#[inline]
fn eq(&self, other: &BlockCheckMode) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(BlockCheckMode::UnsafeBlock(__self_0),
BlockCheckMode::UnsafeBlock(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for BlockCheckMode {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
BlockCheckMode::DefaultBlock =>
::core::fmt::Formatter::write_str(f, "DefaultBlock"),
BlockCheckMode::UnsafeBlock(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"UnsafeBlock", &__self_0),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
BlockCheckMode {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
BlockCheckMode::DefaultBlock => {}
BlockCheckMode::UnsafeBlock(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2271pub enum BlockCheckMode {
2272 DefaultBlock,
2273 UnsafeBlock(UnsafeSource),
2274}
2275
2276#[derive(#[automatically_derived]
impl ::core::marker::Copy for UnsafeSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for UnsafeSource {
#[inline]
fn clone(&self) -> UnsafeSource { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for UnsafeSource {
#[inline]
fn eq(&self, other: &UnsafeSource) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for UnsafeSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
UnsafeSource::CompilerGenerated => "CompilerGenerated",
UnsafeSource::UserProvided => "UserProvided",
})
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for UnsafeSource
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
UnsafeSource::CompilerGenerated => {}
UnsafeSource::UserProvided => {}
}
}
}
};StableHash)]
2277pub enum UnsafeSource {
2278 CompilerGenerated,
2279 UserProvided,
2280}
2281
2282#[derive(#[automatically_derived]
impl ::core::marker::Copy for BodyId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for BodyId {
#[inline]
fn clone(&self) -> BodyId {
let _: ::core::clone::AssertParamIsClone<HirId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for BodyId {
#[inline]
fn eq(&self, other: &BodyId) -> bool { self.hir_id == other.hir_id }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for BodyId {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<HirId>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for BodyId {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.hir_id, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for BodyId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "BodyId",
"hir_id", &&self.hir_id)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for BodyId {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
BodyId { hir_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2283pub struct BodyId {
2284 pub hir_id: HirId,
2285}
2286
2287#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Body<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Body",
"params", &self.params, "value", &&self.value)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Body<'hir> {
#[inline]
fn clone(&self) -> Body<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [Param<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Body<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Body<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Body { params: ref __binding_0, value: ref __binding_1 } =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2309pub struct Body<'hir> {
2310 pub params: &'hir [Param<'hir>],
2311 pub value: &'hir Expr<'hir>,
2312}
2313
2314impl<'hir> Body<'hir> {
2315 pub fn id(&self) -> BodyId {
2316 BodyId { hir_id: self.value.hir_id }
2317 }
2318}
2319
2320#[derive(#[automatically_derived]
impl ::core::clone::Clone for CoroutineKind {
#[inline]
fn clone(&self) -> CoroutineKind {
let _: ::core::clone::AssertParamIsClone<CoroutineDesugaring>;
let _: ::core::clone::AssertParamIsClone<CoroutineSource>;
let _: ::core::clone::AssertParamIsClone<Movability>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for CoroutineKind {
#[inline]
fn eq(&self, other: &CoroutineKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(CoroutineKind::Desugared(__self_0, __self_1),
CoroutineKind::Desugared(__arg1_0, __arg1_1)) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(CoroutineKind::Coroutine(__self_0),
CoroutineKind::Coroutine(__arg1_0)) => __self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for CoroutineKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<CoroutineDesugaring>;
let _: ::core::cmp::AssertParamIsEq<CoroutineSource>;
let _: ::core::cmp::AssertParamIsEq<Movability>;
}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for CoroutineKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
CoroutineKind::Desugared(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"Desugared", __self_0, &__self_1),
CoroutineKind::Coroutine(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Coroutine", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CoroutineKind { }Copy, #[automatically_derived]
impl ::core::hash::Hash for CoroutineKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
CoroutineKind::Desugared(__self_0, __self_1) => {
::core::hash::Hash::hash(__self_0, state);
::core::hash::Hash::hash(__self_1, state)
}
CoroutineKind::Coroutine(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
}
}
}Hash, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
CoroutineKind {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
CoroutineKind::Desugared(ref __binding_0, ref __binding_1)
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
CoroutineKind::Coroutine(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for CoroutineKind {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
CoroutineKind::Desugared(ref __binding_0, ref __binding_1)
=> {
0usize
}
CoroutineKind::Coroutine(ref __binding_0) => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
CoroutineKind::Desugared(ref __binding_0, ref __binding_1)
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
CoroutineKind::Coroutine(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for CoroutineKind {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
CoroutineKind::Desugared(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
CoroutineKind::Coroutine(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CoroutineKind`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
2322pub enum CoroutineKind {
2323 Desugared(CoroutineDesugaring, CoroutineSource),
2325
2326 Coroutine(Movability),
2328}
2329
2330impl CoroutineKind {
2331 pub fn movability(self) -> Movability {
2332 match self {
2333 CoroutineKind::Desugared(CoroutineDesugaring::Async, _)
2334 | CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _) => Movability::Static,
2335 CoroutineKind::Desugared(CoroutineDesugaring::Gen, _) => Movability::Movable,
2336 CoroutineKind::Coroutine(mov) => mov,
2337 }
2338 }
2339
2340 pub fn is_fn_like(self) -> bool {
2341 #[allow(non_exhaustive_omitted_patterns)] match self {
CoroutineKind::Desugared(_, CoroutineSource::Fn) => true,
_ => false,
}matches!(self, CoroutineKind::Desugared(_, CoroutineSource::Fn))
2342 }
2343
2344 pub fn is_async_desugaring(self) -> bool {
2345 #[allow(non_exhaustive_omitted_patterns)] match self {
CoroutineKind::Desugared(CoroutineDesugaring::Async |
CoroutineDesugaring::AsyncGen, _) => true,
_ => false,
}matches!(
2346 self,
2347 CoroutineKind::Desugared(CoroutineDesugaring::Async | CoroutineDesugaring::AsyncGen, _)
2348 )
2349 }
2350
2351 pub fn to_plural_string(&self) -> String {
2352 match self {
2353 CoroutineKind::Desugared(d, CoroutineSource::Fn) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}fn bodies", d))
})format!("{d:#}fn bodies"),
2354 CoroutineKind::Desugared(d, CoroutineSource::Block) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}blocks", d))
})format!("{d:#}blocks"),
2355 CoroutineKind::Desugared(d, CoroutineSource::Closure) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}closure bodies", d))
})format!("{d:#}closure bodies"),
2356 CoroutineKind::Coroutine(_) => "coroutines".to_string(),
2357 }
2358 }
2359}
2360
2361impl fmt::Display for CoroutineKind {
2362 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2363 match self {
2364 CoroutineKind::Desugared(d, k) => {
2365 d.fmt(f)?;
2366 k.fmt(f)
2367 }
2368 CoroutineKind::Coroutine(_) => f.write_str("coroutine"),
2369 }
2370 }
2371}
2372
2373#[derive(#[automatically_derived]
impl ::core::clone::Clone for CoroutineSource {
#[inline]
fn clone(&self) -> CoroutineSource { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for CoroutineSource {
#[inline]
fn eq(&self, other: &CoroutineSource) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for CoroutineSource {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for CoroutineSource {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for CoroutineSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
CoroutineSource::Block => "Block",
CoroutineSource::Closure => "Closure",
CoroutineSource::Fn => "Fn",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CoroutineSource { }Copy, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
CoroutineSource {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
CoroutineSource::Block => {}
CoroutineSource::Closure => {}
CoroutineSource::Fn => {}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for CoroutineSource {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
CoroutineSource::Block => { 0usize }
CoroutineSource::Closure => { 1usize }
CoroutineSource::Fn => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
CoroutineSource::Block => {}
CoroutineSource::Closure => {}
CoroutineSource::Fn => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for CoroutineSource {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { CoroutineSource::Block }
1usize => { CoroutineSource::Closure }
2usize => { CoroutineSource::Fn }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CoroutineSource`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
2379pub enum CoroutineSource {
2380 Block,
2382
2383 Closure,
2385
2386 Fn,
2388}
2389
2390impl fmt::Display for CoroutineSource {
2391 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2392 match self {
2393 CoroutineSource::Block => "block",
2394 CoroutineSource::Closure => "closure body",
2395 CoroutineSource::Fn => "fn body",
2396 }
2397 .fmt(f)
2398 }
2399}
2400
2401#[derive(#[automatically_derived]
impl ::core::clone::Clone for CoroutineDesugaring {
#[inline]
fn clone(&self) -> CoroutineDesugaring { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for CoroutineDesugaring {
#[inline]
fn eq(&self, other: &CoroutineDesugaring) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for CoroutineDesugaring {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for CoroutineDesugaring {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
CoroutineDesugaring::Async => "Async",
CoroutineDesugaring::Gen => "Gen",
CoroutineDesugaring::AsyncGen => "AsyncGen",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CoroutineDesugaring { }Copy, #[automatically_derived]
impl ::core::hash::Hash for CoroutineDesugaring {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
CoroutineDesugaring {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
CoroutineDesugaring::Async => {}
CoroutineDesugaring::Gen => {}
CoroutineDesugaring::AsyncGen => {}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for CoroutineDesugaring {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
CoroutineDesugaring::Async => { 0usize }
CoroutineDesugaring::Gen => { 1usize }
CoroutineDesugaring::AsyncGen => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
CoroutineDesugaring::Async => {}
CoroutineDesugaring::Gen => {}
CoroutineDesugaring::AsyncGen => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for CoroutineDesugaring {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { CoroutineDesugaring::Async }
1usize => { CoroutineDesugaring::Gen }
2usize => { CoroutineDesugaring::AsyncGen }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CoroutineDesugaring`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
2402pub enum CoroutineDesugaring {
2403 Async,
2405
2406 Gen,
2408
2409 AsyncGen,
2412}
2413
2414impl fmt::Display for CoroutineDesugaring {
2415 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2416 match self {
2417 CoroutineDesugaring::Async => {
2418 if f.alternate() {
2419 f.write_str("`async` ")?;
2420 } else {
2421 f.write_str("async ")?
2422 }
2423 }
2424 CoroutineDesugaring::Gen => {
2425 if f.alternate() {
2426 f.write_str("`gen` ")?;
2427 } else {
2428 f.write_str("gen ")?
2429 }
2430 }
2431 CoroutineDesugaring::AsyncGen => {
2432 if f.alternate() {
2433 f.write_str("`async gen` ")?;
2434 } else {
2435 f.write_str("async gen ")?
2436 }
2437 }
2438 }
2439
2440 Ok(())
2441 }
2442}
2443
2444#[derive(#[automatically_derived]
impl ::core::marker::Copy for BodyOwnerKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for BodyOwnerKind {
#[inline]
fn clone(&self) -> BodyOwnerKind {
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for BodyOwnerKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
BodyOwnerKind::Fn => ::core::fmt::Formatter::write_str(f, "Fn"),
BodyOwnerKind::Closure =>
::core::fmt::Formatter::write_str(f, "Closure"),
BodyOwnerKind::Const { inline: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Const",
"inline", &__self_0),
BodyOwnerKind::Static(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Static",
&__self_0),
BodyOwnerKind::GlobalAsm =>
::core::fmt::Formatter::write_str(f, "GlobalAsm"),
}
}
}Debug)]
2445pub enum BodyOwnerKind {
2446 Fn,
2448
2449 Closure,
2451
2452 Const { inline: bool },
2454
2455 Static(Mutability),
2457
2458 GlobalAsm,
2460}
2461
2462impl BodyOwnerKind {
2463 pub fn is_fn_or_closure(self) -> bool {
2464 match self {
2465 BodyOwnerKind::Fn | BodyOwnerKind::Closure => true,
2466 BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(_) | BodyOwnerKind::GlobalAsm => {
2467 false
2468 }
2469 }
2470 }
2471}
2472
2473#[derive(#[automatically_derived]
impl ::core::clone::Clone for ConstContext {
#[inline]
fn clone(&self) -> ConstContext {
let _: ::core::clone::AssertParamIsClone<Mutability>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ConstContext { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for ConstContext {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ConstContext::ConstFn =>
::core::fmt::Formatter::write_str(f, "ConstFn"),
ConstContext::Static(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Static",
&__self_0),
ConstContext::Const { allow_const_fn_promotion: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Const",
"allow_const_fn_promotion", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ConstContext {
#[inline]
fn eq(&self, other: &ConstContext) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(ConstContext::Static(__self_0),
ConstContext::Static(__arg1_0)) => __self_0 == __arg1_0,
(ConstContext::Const { allow_const_fn_promotion: __self_0 },
ConstContext::Const { allow_const_fn_promotion: __arg1_0 })
=> __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ConstContext {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Mutability>;
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq)]
2475pub enum ConstContext {
2476 ConstFn,
2478
2479 Static(Mutability),
2481
2482 Const {
2489 allow_const_fn_promotion: bool,
2493 },
2494}
2495
2496impl ConstContext {
2497 pub fn keyword_name(self) -> &'static str {
2501 match self {
2502 Self::Const { .. } => "const",
2503 Self::Static(Mutability::Not) => "static",
2504 Self::Static(Mutability::Mut) => "static mut",
2505 Self::ConstFn => "const fn",
2506 }
2507 }
2508}
2509
2510impl fmt::Display for ConstContext {
2513 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2514 match *self {
2515 Self::Const { .. } => f.write_fmt(format_args!("constant"))write!(f, "constant"),
2516 Self::Static(_) => f.write_fmt(format_args!("static"))write!(f, "static"),
2517 Self::ConstFn => f.write_fmt(format_args!("constant function"))write!(f, "constant function"),
2518 }
2519 }
2520}
2521
2522impl IntoDiagArg for ConstContext {
2523 fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
2524 DiagArgValue::Str(Cow::Borrowed(match self {
2525 ConstContext::ConstFn => "constant function",
2526 ConstContext::Static(_) => "static",
2527 ConstContext::Const { .. } => "constant",
2528 }))
2529 }
2530}
2531
2532pub type Lit = Spanned<LitKind>;
2534
2535#[derive(#[automatically_derived]
impl ::core::marker::Copy for AnonConst { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AnonConst {
#[inline]
fn clone(&self) -> AnonConst {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AnonConst {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "AnonConst",
"hir_id", &self.hir_id, "def_id", &self.def_id, "body",
&self.body, "span", &&self.span)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for AnonConst {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
AnonConst {
hir_id: ref __binding_0,
def_id: ref __binding_1,
body: ref __binding_2,
span: ref __binding_3 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2544pub struct AnonConst {
2545 #[stable_hash(ignore)]
2546 pub hir_id: HirId,
2547 pub def_id: LocalDefId,
2548 pub body: BodyId,
2549 pub span: Span,
2550}
2551
2552#[derive(#[automatically_derived]
impl ::core::marker::Copy for ConstBlock { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ConstBlock {
#[inline]
fn clone(&self) -> ConstBlock {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ConstBlock {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "ConstBlock",
"hir_id", &self.hir_id, "def_id", &self.def_id, "body",
&&self.body)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for ConstBlock {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ConstBlock {
hir_id: ref __binding_0,
def_id: ref __binding_1,
body: ref __binding_2 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2554pub struct ConstBlock {
2555 #[stable_hash(ignore)]
2556 pub hir_id: HirId,
2557 pub def_id: LocalDefId,
2558 pub body: BodyId,
2559}
2560
2561#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Expr<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "Expr",
"hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Expr<'hir> {
#[inline]
fn clone(&self) -> Expr<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<ExprKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Expr<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Expr<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Expr {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2570pub struct Expr<'hir> {
2571 #[stable_hash(ignore)]
2572 pub hir_id: HirId,
2573 pub kind: ExprKind<'hir>,
2574 pub span: Span,
2575}
2576
2577impl Expr<'_> {
2578 pub fn precedence(&self, has_attr: &dyn Fn(HirId) -> bool) -> ExprPrecedence {
2579 let prefix_attrs_precedence = || -> ExprPrecedence {
2580 if has_attr(self.hir_id) { ExprPrecedence::Prefix } else { ExprPrecedence::Unambiguous }
2581 };
2582
2583 match &self.kind {
2584 ExprKind::Closure(closure) => match closure.fn_decl.output {
2585 FnRetTy::DefaultReturn(_) => ExprPrecedence::Jump,
2586 FnRetTy::Return(_) => prefix_attrs_precedence(),
2587 },
2588
2589 ExprKind::Break(..)
2590 | ExprKind::Ret(..)
2591 | ExprKind::Yield(..)
2592 | ExprKind::Become(..) => ExprPrecedence::Jump,
2593
2594 ExprKind::Binary(op, ..) => op.node.precedence(),
2596 ExprKind::Cast(..) => ExprPrecedence::Cast,
2597
2598 ExprKind::Assign(..) | ExprKind::AssignOp(..) => ExprPrecedence::Assign,
2599
2600 ExprKind::AddrOf(..) => ExprPrecedence::Prefix,
2602
2603 ExprKind::Let(..) | ExprKind::Unary(..) => ExprPrecedence::Prefix,
2608
2609 ExprKind::Array(_)
2611 | ExprKind::Block(..)
2612 | ExprKind::Call(..)
2613 | ExprKind::ConstBlock(_)
2614 | ExprKind::Continue(..)
2615 | ExprKind::Field(..)
2616 | ExprKind::If(..)
2617 | ExprKind::Index(..)
2618 | ExprKind::InlineAsm(..)
2619 | ExprKind::Lit(_)
2620 | ExprKind::Loop(..)
2621 | ExprKind::Match(..)
2622 | ExprKind::MethodCall(..)
2623 | ExprKind::OffsetOf(..)
2624 | ExprKind::Path(..)
2625 | ExprKind::Repeat(..)
2626 | ExprKind::Struct(..)
2627 | ExprKind::Tup(_)
2628 | ExprKind::Type(..)
2629 | ExprKind::UnsafeBinderCast(..)
2630 | ExprKind::Use(..)
2631 | ExprKind::Err(_) => prefix_attrs_precedence(),
2632
2633 ExprKind::DropTemps(expr, ..) => expr.precedence(has_attr),
2634 }
2635 }
2636
2637 pub fn is_syntactic_place_expr(&self) -> bool {
2642 self.is_place_expr(|_| true)
2643 }
2644
2645 pub fn is_place_expr(&self, mut allow_projections_from: impl FnMut(&Self) -> bool) -> bool {
2650 match self.kind {
2651 ExprKind::Path(QPath::Resolved(_, ref path)) => {
2652 #[allow(non_exhaustive_omitted_patterns)] match path.res {
Res::Local(..) | Res::Def(DefKind::Static { .. }, _) | Res::Err => true,
_ => false,
}matches!(path.res, Res::Local(..) | Res::Def(DefKind::Static { .. }, _) | Res::Err)
2653 }
2654
2655 ExprKind::Type(ref e, _) => e.is_place_expr(allow_projections_from),
2659
2660 ExprKind::UnsafeBinderCast(_, e, _) => e.is_place_expr(allow_projections_from),
2662
2663 ExprKind::Unary(UnOp::Deref, _) => true,
2664
2665 ExprKind::Field(ref base, _) | ExprKind::Index(ref base, _, _) => {
2666 allow_projections_from(base) || base.is_place_expr(allow_projections_from)
2667 }
2668
2669 ExprKind::Err(_guar)
2671 | ExprKind::Let(&LetExpr { recovered: ast::Recovered::Yes(_guar), .. }) => true,
2672
2673 ExprKind::Path(QPath::TypeRelative(..))
2676 | ExprKind::Call(..)
2677 | ExprKind::MethodCall(..)
2678 | ExprKind::Use(..)
2679 | ExprKind::Struct(..)
2680 | ExprKind::Tup(..)
2681 | ExprKind::If(..)
2682 | ExprKind::Match(..)
2683 | ExprKind::Closure { .. }
2684 | ExprKind::Block(..)
2685 | ExprKind::Repeat(..)
2686 | ExprKind::Array(..)
2687 | ExprKind::Break(..)
2688 | ExprKind::Continue(..)
2689 | ExprKind::Ret(..)
2690 | ExprKind::Become(..)
2691 | ExprKind::Let(..)
2692 | ExprKind::Loop(..)
2693 | ExprKind::Assign(..)
2694 | ExprKind::InlineAsm(..)
2695 | ExprKind::OffsetOf(..)
2696 | ExprKind::AssignOp(..)
2697 | ExprKind::Lit(_)
2698 | ExprKind::ConstBlock(..)
2699 | ExprKind::Unary(..)
2700 | ExprKind::AddrOf(..)
2701 | ExprKind::Binary(..)
2702 | ExprKind::Yield(..)
2703 | ExprKind::Cast(..)
2704 | ExprKind::DropTemps(..) => false,
2705 }
2706 }
2707
2708 pub fn range_span(&self) -> Option<Span> {
2711 is_range_literal(self).then(|| self.span.parent_callsite().unwrap())
2712 }
2713
2714 pub fn is_size_lit(&self) -> bool {
2717 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ExprKind::Lit(Lit {
node: LitKind::Int(_,
LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)), ..
}) => true,
_ => false,
}matches!(
2718 self.kind,
2719 ExprKind::Lit(Lit {
2720 node: LitKind::Int(_, LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)),
2721 ..
2722 })
2723 )
2724 }
2725
2726 pub fn peel_drop_temps(&self) -> &Self {
2732 let mut expr = self;
2733 while let ExprKind::DropTemps(inner) = &expr.kind {
2734 expr = inner;
2735 }
2736 expr
2737 }
2738
2739 pub fn peel_blocks(&self) -> &Self {
2740 let mut expr = self;
2741 while let ExprKind::Block(Block { expr: Some(inner), .. }, _) = &expr.kind {
2742 expr = inner;
2743 }
2744 expr
2745 }
2746
2747 pub fn peel_borrows(&self) -> &Self {
2748 let mut expr = self;
2749 while let ExprKind::AddrOf(.., inner) = &expr.kind {
2750 expr = inner;
2751 }
2752 expr
2753 }
2754
2755 pub fn can_have_side_effects(&self) -> bool {
2756 match self.peel_drop_temps().kind {
2757 ExprKind::Path(_) | ExprKind::Lit(_) | ExprKind::OffsetOf(..) | ExprKind::Use(..) => {
2758 false
2759 }
2760 ExprKind::Type(base, _)
2761 | ExprKind::Unary(_, base)
2762 | ExprKind::Field(base, _)
2763 | ExprKind::Index(base, _, _)
2764 | ExprKind::AddrOf(.., base)
2765 | ExprKind::Cast(base, _)
2766 | ExprKind::UnsafeBinderCast(_, base, _) => {
2767 base.can_have_side_effects()
2771 }
2772 ExprKind::Binary(_, lhs, rhs) => {
2773 lhs.can_have_side_effects() || rhs.can_have_side_effects()
2777 }
2778 ExprKind::Struct(_, fields, init) => {
2779 let init_side_effects = match init {
2780 StructTailExpr::Base(init) => init.can_have_side_effects(),
2781 StructTailExpr::DefaultFields(_)
2782 | StructTailExpr::None
2783 | StructTailExpr::NoneWithError(_) => false,
2784 };
2785 fields.iter().map(|field| field.expr).any(|e| e.can_have_side_effects())
2786 || init_side_effects
2787 }
2788
2789 ExprKind::Array(args)
2790 | ExprKind::Tup(args)
2791 | ExprKind::Call(
2792 Expr {
2793 kind:
2794 ExprKind::Path(QPath::Resolved(
2795 None,
2796 Path { res: Res::Def(DefKind::Ctor(_, CtorKind::Fn), _), .. },
2797 )),
2798 ..
2799 },
2800 args,
2801 ) => args.iter().any(|arg| arg.can_have_side_effects()),
2802 ExprKind::Repeat(arg, _) => arg.can_have_side_effects(),
2803 ExprKind::If(..)
2804 | ExprKind::Match(..)
2805 | ExprKind::MethodCall(..)
2806 | ExprKind::Call(..)
2807 | ExprKind::Closure { .. }
2808 | ExprKind::Block(..)
2809 | ExprKind::Break(..)
2810 | ExprKind::Continue(..)
2811 | ExprKind::Ret(..)
2812 | ExprKind::Become(..)
2813 | ExprKind::Let(..)
2814 | ExprKind::Loop(..)
2815 | ExprKind::Assign(..)
2816 | ExprKind::InlineAsm(..)
2817 | ExprKind::AssignOp(..)
2818 | ExprKind::ConstBlock(..)
2819 | ExprKind::Yield(..)
2820 | ExprKind::DropTemps(..)
2821 | ExprKind::Err(_) => true,
2822 }
2823 }
2824
2825 pub fn is_approximately_pattern(&self) -> bool {
2827 match &self.kind {
2828 ExprKind::Array(_)
2829 | ExprKind::Call(..)
2830 | ExprKind::Tup(_)
2831 | ExprKind::Lit(_)
2832 | ExprKind::Path(_)
2833 | ExprKind::Struct(..) => true,
2834 _ => false,
2835 }
2836 }
2837
2838 pub fn equivalent_for_indexing(&self, other: &Expr<'_>) -> bool {
2843 match (self.kind, other.kind) {
2844 (ExprKind::Lit(lit1), ExprKind::Lit(lit2)) => lit1.node == lit2.node,
2845 (
2846 ExprKind::Path(QPath::Resolved(None, path1)),
2847 ExprKind::Path(QPath::Resolved(None, path2)),
2848 ) => path1.res == path2.res,
2849 (
2850 ExprKind::Struct(
2851 &QPath::Resolved(None, &Path { res: Res::Def(_, path1_def_id), .. }),
2852 args1,
2853 StructTailExpr::None,
2854 ),
2855 ExprKind::Struct(
2856 &QPath::Resolved(None, &Path { res: Res::Def(_, path2_def_id), .. }),
2857 args2,
2858 StructTailExpr::None,
2859 ),
2860 ) => {
2861 path2_def_id == path1_def_id
2862 && is_range_literal(self)
2863 && is_range_literal(other)
2864 && std::iter::zip(args1, args2)
2865 .all(|(a, b)| a.expr.equivalent_for_indexing(b.expr))
2866 }
2867 _ => false,
2868 }
2869 }
2870
2871 pub fn method_ident(&self) -> Option<Ident> {
2872 match self.kind {
2873 ExprKind::MethodCall(receiver_method, ..) => Some(receiver_method.ident),
2874 ExprKind::Unary(_, expr) | ExprKind::AddrOf(.., expr) => expr.method_ident(),
2875 _ => None,
2876 }
2877 }
2878}
2879
2880pub fn is_range_literal(expr: &Expr<'_>) -> bool {
2883 if let ExprKind::Struct(QPath::Resolved(None, path), _, StructTailExpr::None) = expr.kind
2884 && let [.., segment] = path.segments
2885 && let sym::RangeFrom
2886 | sym::RangeFull
2887 | sym::Range
2888 | sym::RangeToInclusive
2889 | sym::RangeTo
2890 | sym::RangeFromCopy
2891 | sym::RangeCopy
2892 | sym::RangeInclusiveCopy
2893 | sym::RangeToInclusiveCopy = segment.ident.name
2894 && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2895 {
2896 true
2897 } else if let ExprKind::Call(func, _) = &expr.kind
2898 && let ExprKind::Path(QPath::Resolved(None, path)) = func.kind
2899 && let [.., segment] = path.segments
2900 && let sym::range_inclusive_new = segment.ident.name
2901 && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2902 {
2903 true
2904 } else {
2905 false
2906 }
2907}
2908
2909pub fn expr_needs_parens(expr: &Expr<'_>) -> bool {
2916 match expr.kind {
2917 ExprKind::Cast(_, _) | ExprKind::Binary(_, _, _) => true,
2919 _ if is_range_literal(expr) => true,
2921 _ => false,
2922 }
2923}
2924
2925#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ExprKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ExprKind::ConstBlock(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ConstBlock", &__self_0),
ExprKind::Array(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Array",
&__self_0),
ExprKind::Call(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Call",
__self_0, &__self_1),
ExprKind::MethodCall(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f,
"MethodCall", __self_0, __self_1, __self_2, &__self_3),
ExprKind::Use(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Use",
__self_0, &__self_1),
ExprKind::Tup(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tup",
&__self_0),
ExprKind::Binary(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Binary",
__self_0, __self_1, &__self_2),
ExprKind::Unary(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Unary",
__self_0, &__self_1),
ExprKind::Lit(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Lit",
&__self_0),
ExprKind::Cast(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Cast",
__self_0, &__self_1),
ExprKind::Type(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Type",
__self_0, &__self_1),
ExprKind::DropTemps(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"DropTemps", &__self_0),
ExprKind::Let(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Let",
&__self_0),
ExprKind::If(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "If",
__self_0, __self_1, &__self_2),
ExprKind::Loop(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f, "Loop",
__self_0, __self_1, __self_2, &__self_3),
ExprKind::Match(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Match",
__self_0, __self_1, &__self_2),
ExprKind::Closure(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Closure", &__self_0),
ExprKind::Block(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Block",
__self_0, &__self_1),
ExprKind::Assign(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Assign",
__self_0, __self_1, &__self_2),
ExprKind::AssignOp(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f,
"AssignOp", __self_0, __self_1, &__self_2),
ExprKind::Field(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Field",
__self_0, &__self_1),
ExprKind::Index(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Index",
__self_0, __self_1, &__self_2),
ExprKind::Path(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
&__self_0),
ExprKind::AddrOf(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "AddrOf",
__self_0, __self_1, &__self_2),
ExprKind::Break(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Break",
__self_0, &__self_1),
ExprKind::Continue(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Continue", &__self_0),
ExprKind::Ret(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ret",
&__self_0),
ExprKind::Become(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Become",
&__self_0),
ExprKind::InlineAsm(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"InlineAsm", &__self_0),
ExprKind::OffsetOf(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"OffsetOf", __self_0, &__self_1),
ExprKind::Struct(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Struct",
__self_0, __self_1, &__self_2),
ExprKind::Repeat(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Repeat",
__self_0, &__self_1),
ExprKind::Yield(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Yield",
__self_0, &__self_1),
ExprKind::UnsafeBinderCast(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f,
"UnsafeBinderCast", __self_0, __self_1, &__self_2),
ExprKind::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ExprKind<'hir> {
#[inline]
fn clone(&self) -> ExprKind<'hir> {
let _: ::core::clone::AssertParamIsClone<ConstBlock>;
let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir PathSegment<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
let _: ::core::clone::AssertParamIsClone<BinOp>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<UnOp>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Lit>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir LetExpr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<Label>>;
let _: ::core::clone::AssertParamIsClone<LoopSource>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Arm<'hir>]>;
let _: ::core::clone::AssertParamIsClone<MatchSource>;
let _: ::core::clone::AssertParamIsClone<&'hir Closure<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<Label>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<AssignOp>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
let _: ::core::clone::AssertParamIsClone<BorrowKind>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Destination>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir InlineAsm<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Ident]>;
let _: ::core::clone::AssertParamIsClone<&'hir QPath<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [ExprField<'hir>]>;
let _: ::core::clone::AssertParamIsClone<StructTailExpr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<YieldSource>;
let _: ::core::clone::AssertParamIsClone<UnsafeBinderCastKind>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
let _: ::core::clone::AssertParamIsClone<rustc_span::ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ExprKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ExprKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ExprKind::ConstBlock(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::Array(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::Call(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::MethodCall(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
ExprKind::Use(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::Tup(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::Binary(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ExprKind::Unary(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::Lit(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::Cast(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::Type(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::DropTemps(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::Let(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::If(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ExprKind::Loop(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
ExprKind::Match(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ExprKind::Closure(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::Block(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::Assign(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ExprKind::AssignOp(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ExprKind::Field(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::Index(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ExprKind::Path(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::AddrOf(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ExprKind::Break(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::Continue(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::Ret(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::Become(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::InlineAsm(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExprKind::OffsetOf(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::Struct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ExprKind::Repeat(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::Yield(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ExprKind::UnsafeBinderCast(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ExprKind::Err(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
2926pub enum ExprKind<'hir> {
2927 ConstBlock(ConstBlock),
2929 Array(&'hir [Expr<'hir>]),
2931 Call(&'hir Expr<'hir>, &'hir [Expr<'hir>]),
2938 MethodCall(&'hir PathSegment<'hir>, &'hir Expr<'hir>, &'hir [Expr<'hir>], Span),
2955 Use(&'hir Expr<'hir>, Span),
2957 Tup(&'hir [Expr<'hir>]),
2959 Binary(BinOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2961 Unary(UnOp, &'hir Expr<'hir>),
2963 Lit(Lit),
2965 Cast(&'hir Expr<'hir>, &'hir Ty<'hir>),
2967 Type(&'hir Expr<'hir>, &'hir Ty<'hir>),
2969 DropTemps(&'hir Expr<'hir>),
2975 Let(&'hir LetExpr<'hir>),
2980 If(&'hir Expr<'hir>, &'hir Expr<'hir>, Option<&'hir Expr<'hir>>),
2989 Loop(&'hir Block<'hir>, Option<Label>, LoopSource, Span),
2995 Match(&'hir Expr<'hir>, &'hir [Arm<'hir>], MatchSource),
2998 Closure(&'hir Closure<'hir>),
3005 Block(&'hir Block<'hir>, Option<Label>),
3007
3008 Assign(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
3010 AssignOp(AssignOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
3014 Field(&'hir Expr<'hir>, Ident),
3016 Index(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
3020
3021 Path(QPath<'hir>),
3023
3024 AddrOf(BorrowKind, Mutability, &'hir Expr<'hir>),
3026 Break(Destination, Option<&'hir Expr<'hir>>),
3028 Continue(Destination),
3030 Ret(Option<&'hir Expr<'hir>>),
3032 Become(&'hir Expr<'hir>),
3034
3035 InlineAsm(&'hir InlineAsm<'hir>),
3037
3038 OffsetOf(&'hir Ty<'hir>, &'hir [Ident]),
3040
3041 Struct(&'hir QPath<'hir>, &'hir [ExprField<'hir>], StructTailExpr<'hir>),
3046
3047 Repeat(&'hir Expr<'hir>, &'hir ConstArg<'hir>),
3052
3053 Yield(&'hir Expr<'hir>, YieldSource),
3055
3056 UnsafeBinderCast(UnsafeBinderCastKind, &'hir Expr<'hir>, Option<&'hir Ty<'hir>>),
3059
3060 Err(rustc_span::ErrorGuaranteed),
3062}
3063
3064#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for StructTailExpr<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
StructTailExpr::None =>
::core::fmt::Formatter::write_str(f, "None"),
StructTailExpr::Base(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Base",
&__self_0),
StructTailExpr::DefaultFields(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"DefaultFields", &__self_0),
StructTailExpr::NoneWithError(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"NoneWithError", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for StructTailExpr<'hir> {
#[inline]
fn clone(&self) -> StructTailExpr<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for StructTailExpr<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
StructTailExpr<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
StructTailExpr::None => {}
StructTailExpr::Base(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
StructTailExpr::DefaultFields(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
StructTailExpr::NoneWithError(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3065pub enum StructTailExpr<'hir> {
3066 None,
3068 Base(&'hir Expr<'hir>),
3071 DefaultFields(Span),
3075 NoneWithError(ErrorGuaranteed),
3081}
3082
3083#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for QPath<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
QPath::Resolved(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"Resolved", __self_0, &__self_1),
QPath::TypeRelative(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"TypeRelative", __self_0, &__self_1),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for QPath<'hir> {
#[inline]
fn clone(&self) -> QPath<'hir> {
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Path<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir PathSegment<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for QPath<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
QPath<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
QPath::Resolved(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
QPath::TypeRelative(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3089pub enum QPath<'hir> {
3090 Resolved(Option<&'hir Ty<'hir>>, &'hir Path<'hir>),
3097
3098 TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
3105}
3106
3107impl<'hir> QPath<'hir> {
3108 pub fn span(&self) -> Span {
3110 match *self {
3111 QPath::Resolved(_, path) => path.span,
3112 QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
3113 }
3114 }
3115
3116 pub fn qself_span(&self) -> Span {
3119 match *self {
3120 QPath::Resolved(_, path) => path.span,
3121 QPath::TypeRelative(qself, _) => qself.span,
3122 }
3123 }
3124}
3125
3126#[derive(#[automatically_derived]
impl ::core::marker::Copy for LocalSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LocalSource {
#[inline]
fn clone(&self) -> LocalSource { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for LocalSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
LocalSource::Normal => "Normal",
LocalSource::AsyncFn => "AsyncFn",
LocalSource::AwaitDesugar => "AwaitDesugar",
LocalSource::AssignDesugar => "AssignDesugar",
LocalSource::Contract => "Contract",
})
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for LocalSource
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
LocalSource::Normal => {}
LocalSource::AsyncFn => {}
LocalSource::AwaitDesugar => {}
LocalSource::AssignDesugar => {}
LocalSource::Contract => {}
}
}
}
};StableHash)]
3128pub enum LocalSource {
3129 Normal,
3131 AsyncFn,
3142 AwaitDesugar,
3144 AssignDesugar,
3146 Contract,
3148}
3149
3150#[derive(#[automatically_derived]
impl ::core::marker::Copy for MatchSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for MatchSource {
#[inline]
fn clone(&self) -> MatchSource {
let _: ::core::clone::AssertParamIsClone<HirId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for MatchSource {
#[inline]
fn eq(&self, other: &MatchSource) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(MatchSource::TryDesugar(__self_0),
MatchSource::TryDesugar(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for MatchSource {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<HirId>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for MatchSource {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
MatchSource::TryDesugar(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for MatchSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
MatchSource::Normal =>
::core::fmt::Formatter::write_str(f, "Normal"),
MatchSource::Postfix =>
::core::fmt::Formatter::write_str(f, "Postfix"),
MatchSource::ForLoopDesugar =>
::core::fmt::Formatter::write_str(f, "ForLoopDesugar"),
MatchSource::TryDesugar(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TryDesugar", &__self_0),
MatchSource::AwaitDesugar =>
::core::fmt::Formatter::write_str(f, "AwaitDesugar"),
MatchSource::FormatArgs =>
::core::fmt::Formatter::write_str(f, "FormatArgs"),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for MatchSource
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
MatchSource::Normal => {}
MatchSource::Postfix => {}
MatchSource::ForLoopDesugar => {}
MatchSource::TryDesugar(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
MatchSource::AwaitDesugar => {}
MatchSource::FormatArgs => {}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for MatchSource {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
MatchSource::Normal => { 0usize }
MatchSource::Postfix => { 1usize }
MatchSource::ForLoopDesugar => { 2usize }
MatchSource::TryDesugar(ref __binding_0) => { 3usize }
MatchSource::AwaitDesugar => { 4usize }
MatchSource::FormatArgs => { 5usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
MatchSource::Normal => {}
MatchSource::Postfix => {}
MatchSource::ForLoopDesugar => {}
MatchSource::TryDesugar(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
MatchSource::AwaitDesugar => {}
MatchSource::FormatArgs => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for MatchSource {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { MatchSource::Normal }
1usize => { MatchSource::Postfix }
2usize => { MatchSource::ForLoopDesugar }
3usize => {
MatchSource::TryDesugar(::rustc_serialize::Decodable::decode(__decoder))
}
4usize => { MatchSource::AwaitDesugar }
5usize => { MatchSource::FormatArgs }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `MatchSource`, expected 0..6, actual {0}",
n));
}
}
}
}
};Decodable)]
3152pub enum MatchSource {
3153 Normal,
3155 Postfix,
3157 ForLoopDesugar,
3159 TryDesugar(HirId),
3161 AwaitDesugar,
3163 FormatArgs,
3165}
3166
3167impl MatchSource {
3168 #[inline]
3169 pub const fn name(self) -> &'static str {
3170 use MatchSource::*;
3171 match self {
3172 Normal => "match",
3173 Postfix => ".match",
3174 ForLoopDesugar => "for",
3175 TryDesugar(_) => "?",
3176 AwaitDesugar => ".await",
3177 FormatArgs => "format_args!()",
3178 }
3179 }
3180}
3181
3182#[derive(#[automatically_derived]
impl ::core::marker::Copy for LoopSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LoopSource {
#[inline]
fn clone(&self) -> LoopSource { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LoopSource {
#[inline]
fn eq(&self, other: &LoopSource) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for LoopSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
LoopSource::Loop => "Loop",
LoopSource::While => "While",
LoopSource::ForLoop => "ForLoop",
})
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for LoopSource {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
LoopSource::Loop => {}
LoopSource::While => {}
LoopSource::ForLoop => {}
}
}
}
};StableHash)]
3184pub enum LoopSource {
3185 Loop,
3187 While,
3189 ForLoop,
3191}
3192
3193impl LoopSource {
3194 pub fn name(self) -> &'static str {
3195 match self {
3196 LoopSource::Loop => "loop",
3197 LoopSource::While => "while",
3198 LoopSource::ForLoop => "for",
3199 }
3200 }
3201}
3202
3203#[derive(#[automatically_derived]
impl ::core::marker::Copy for LoopIdError { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LoopIdError {
#[inline]
fn clone(&self) -> LoopIdError { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for LoopIdError {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
LoopIdError::OutsideLoopScope => "OutsideLoopScope",
LoopIdError::UnlabeledCfInWhileCondition =>
"UnlabeledCfInWhileCondition",
LoopIdError::UnresolvedLabel => "UnresolvedLabel",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for LoopIdError {
#[inline]
fn eq(&self, other: &LoopIdError) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for LoopIdError
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
LoopIdError::OutsideLoopScope => {}
LoopIdError::UnlabeledCfInWhileCondition => {}
LoopIdError::UnresolvedLabel => {}
}
}
}
};StableHash)]
3204pub enum LoopIdError {
3205 OutsideLoopScope,
3206 UnlabeledCfInWhileCondition,
3207 UnresolvedLabel,
3208}
3209
3210impl fmt::Display for LoopIdError {
3211 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3212 f.write_str(match self {
3213 LoopIdError::OutsideLoopScope => "not inside loop scope",
3214 LoopIdError::UnlabeledCfInWhileCondition => {
3215 "unlabeled control flow (break or continue) in while condition"
3216 }
3217 LoopIdError::UnresolvedLabel => "label not found",
3218 })
3219 }
3220}
3221
3222#[derive(#[automatically_derived]
impl ::core::marker::Copy for Destination { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Destination {
#[inline]
fn clone(&self) -> Destination {
let _: ::core::clone::AssertParamIsClone<Option<Label>>;
let _: ::core::clone::AssertParamIsClone<Result<HirId, LoopIdError>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Destination {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Destination",
"label", &self.label, "target_id", &&self.target_id)
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for Destination {
#[inline]
fn eq(&self, other: &Destination) -> bool {
self.label == other.label && self.target_id == other.target_id
}
}PartialEq, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Destination
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Destination {
label: ref __binding_0, target_id: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3223pub struct Destination {
3224 pub label: Option<Label>,
3226
3227 pub target_id: Result<HirId, LoopIdError>,
3230}
3231
3232#[derive(#[automatically_derived]
impl ::core::marker::Copy for YieldSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for YieldSource {
#[inline]
fn clone(&self) -> YieldSource {
let _: ::core::clone::AssertParamIsClone<Option<HirId>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for YieldSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
YieldSource::Await { expr: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Await",
"expr", &__self_0),
YieldSource::Yield =>
::core::fmt::Formatter::write_str(f, "Yield"),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for YieldSource
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
YieldSource::Await { expr: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
YieldSource::Yield => {}
}
}
}
};StableHash)]
3234pub enum YieldSource {
3235 Await { expr: Option<HirId> },
3237 Yield,
3239}
3240
3241impl fmt::Display for YieldSource {
3242 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3243 f.write_str(match self {
3244 YieldSource::Await { .. } => "`await`",
3245 YieldSource::Yield => "`yield`",
3246 })
3247 }
3248}
3249
3250#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for MutTy<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "MutTy", "ty",
&self.ty, "mutbl", &&self.mutbl)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for MutTy<'hir> {
#[inline]
fn clone(&self) -> MutTy<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for MutTy<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
MutTy<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
MutTy { ty: ref __binding_0, mutbl: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3253pub struct MutTy<'hir> {
3254 pub ty: &'hir Ty<'hir>,
3255 pub mutbl: Mutability,
3256}
3257
3258#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnSig<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "FnSig",
"header", &self.header, "decl", &self.decl, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnSig<'hir> {
#[inline]
fn clone(&self) -> FnSig<'hir> {
let _: ::core::clone::AssertParamIsClone<FnHeader>;
let _: ::core::clone::AssertParamIsClone<&'hir FnDecl<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnSig<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
FnSig<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
FnSig {
header: ref __binding_0,
decl: ref __binding_1,
span: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3261pub struct FnSig<'hir> {
3262 pub header: FnHeader,
3263 pub decl: &'hir FnDecl<'hir>,
3264 pub span: Span,
3265}
3266
3267#[derive(#[automatically_derived]
impl ::core::marker::Copy for TraitItemId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for TraitItemId {
#[inline]
fn clone(&self) -> TraitItemId {
let _: ::core::clone::AssertParamIsClone<OwnerId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for TraitItemId {
#[inline]
fn eq(&self, other: &TraitItemId) -> bool {
self.owner_id == other.owner_id
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for TraitItemId {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<OwnerId>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for TraitItemId {
fn encode(&self, __encoder: &mut __E) {
match *self {
TraitItemId { owner_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for TraitItemId {
fn decode(__decoder: &mut __D) -> Self {
TraitItemId {
owner_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for TraitItemId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "TraitItemId",
"owner_id", &&self.owner_id)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for TraitItemId
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TraitItemId { owner_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3271pub struct TraitItemId {
3272 pub owner_id: OwnerId,
3273}
3274
3275impl TraitItemId {
3276 #[inline]
3277 pub fn hir_id(&self) -> HirId {
3278 HirId::make_owner(self.owner_id.def_id)
3280 }
3281}
3282
3283#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitItem<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["ident", "owner_id", "generics", "kind", "span", "defaultness"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.owner_id, &self.generics, &self.kind,
&self.span, &&self.defaultness];
::core::fmt::Formatter::debug_struct_fields_finish(f, "TraitItem",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitItem<'hir> {
#[inline]
fn clone(&self) -> TraitItem<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<OwnerId>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<TraitItemKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Defaultness>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitItem<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
TraitItem<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TraitItem {
ident: ref __binding_0,
owner_id: ref __binding_1,
generics: ref __binding_2,
kind: ref __binding_3,
span: ref __binding_4,
defaultness: ref __binding_5 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3288pub struct TraitItem<'hir> {
3289 pub ident: Ident,
3290 pub owner_id: OwnerId,
3291 pub generics: &'hir Generics<'hir>,
3292 pub kind: TraitItemKind<'hir>,
3293 pub span: Span,
3294 pub defaultness: Defaultness,
3295}
3296
3297macro_rules! expect_methods_self_kind {
3298 ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3299 $(
3300 #[track_caller]
3301 pub fn $name(&self) -> $ret_ty {
3302 let $pat = &self.kind else { expect_failed(stringify!($name), self) };
3303 $ret_val
3304 }
3305 )*
3306 }
3307}
3308
3309macro_rules! expect_methods_self {
3310 ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3311 $(
3312 #[track_caller]
3313 pub fn $name(&self) -> $ret_ty {
3314 let $pat = self else { expect_failed(stringify!($name), self) };
3315 $ret_val
3316 }
3317 )*
3318 }
3319}
3320
3321#[track_caller]
3322fn expect_failed<T: fmt::Debug>(ident: &'static str, found: T) -> ! {
3323 {
::core::panicking::panic_fmt(format_args!("{0}: found {1:?}", ident,
found));
}panic!("{ident}: found {found:?}")
3324}
3325
3326impl<'hir> TraitItem<'hir> {
3327 #[inline]
3328 pub fn hir_id(&self) -> HirId {
3329 HirId::make_owner(self.owner_id.def_id)
3331 }
3332
3333 pub fn trait_item_id(&self) -> TraitItemId {
3334 TraitItemId { owner_id: self.owner_id }
3335 }
3336
3337 #[track_caller]
pub fn expect_type(&self) -> (GenericBounds<'hir>, Option<&'hir Ty<'hir>>) {
let TraitItemKind::Type(bounds, ty) =
&self.kind else { expect_failed("expect_type", self) };
(bounds, *ty)
}expect_methods_self_kind! {
3338 expect_const, (&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>),
3339 TraitItemKind::Const(ty, rhs), (ty, *rhs);
3340
3341 expect_fn, (&FnSig<'hir>, &TraitFn<'hir>),
3342 TraitItemKind::Fn(ty, trfn), (ty, trfn);
3343
3344 expect_type, (GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3345 TraitItemKind::Type(bounds, ty), (bounds, *ty);
3346 }
3347}
3348
3349#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitFn<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TraitFn::Required(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Required", &__self_0),
TraitFn::Provided(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Provided", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitFn<'hir> {
#[inline]
fn clone(&self) -> TraitFn<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [Option<Ident>]>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitFn<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
TraitFn<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
TraitFn::Required(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TraitFn::Provided(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3351pub enum TraitFn<'hir> {
3352 Required(&'hir [Option<Ident>]),
3354
3355 Provided(BodyId),
3357}
3358
3359#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitItemKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TraitItemKind::Const(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Const",
__self_0, &__self_1),
TraitItemKind::Fn(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Fn",
__self_0, &__self_1),
TraitItemKind::Type(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Type",
__self_0, &__self_1),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitItemKind<'hir> {
#[inline]
fn clone(&self) -> TraitItemKind<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<ConstItemRhs<'hir>>>;
let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
let _: ::core::clone::AssertParamIsClone<TraitFn<'hir>>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitItemKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
TraitItemKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
TraitItemKind::Const(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TraitItemKind::Fn(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TraitItemKind::Type(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3361pub enum TraitItemKind<'hir> {
3362 Const(&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>),
3364 Fn(FnSig<'hir>, TraitFn<'hir>),
3366 Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3369}
3370
3371#[derive(#[automatically_derived]
impl ::core::marker::Copy for ImplItemId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ImplItemId {
#[inline]
fn clone(&self) -> ImplItemId {
let _: ::core::clone::AssertParamIsClone<OwnerId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ImplItemId {
#[inline]
fn eq(&self, other: &ImplItemId) -> bool {
self.owner_id == other.owner_id
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplItemId {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<OwnerId>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ImplItemId {
fn encode(&self, __encoder: &mut __E) {
match *self {
ImplItemId { owner_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ImplItemId {
fn decode(__decoder: &mut __D) -> Self {
ImplItemId {
owner_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ImplItemId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "ImplItemId",
"owner_id", &&self.owner_id)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for ImplItemId {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ImplItemId { owner_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3375pub struct ImplItemId {
3376 pub owner_id: OwnerId,
3377}
3378
3379impl ImplItemId {
3380 #[inline]
3381 pub fn hir_id(&self) -> HirId {
3382 HirId::make_owner(self.owner_id.def_id)
3384 }
3385}
3386
3387#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ImplItem<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["ident", "owner_id", "generics", "kind", "impl_kind", "span"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.owner_id, &self.generics, &self.kind,
&self.impl_kind, &&self.span];
::core::fmt::Formatter::debug_struct_fields_finish(f, "ImplItem",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ImplItem<'hir> {
#[inline]
fn clone(&self) -> ImplItem<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<OwnerId>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<ImplItemKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<ImplItemImplKind>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ImplItem<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ImplItem<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ImplItem {
ident: ref __binding_0,
owner_id: ref __binding_1,
generics: ref __binding_2,
kind: ref __binding_3,
impl_kind: ref __binding_4,
span: ref __binding_5 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3391pub struct ImplItem<'hir> {
3392 pub ident: Ident,
3393 pub owner_id: OwnerId,
3394 pub generics: &'hir Generics<'hir>,
3395 pub kind: ImplItemKind<'hir>,
3396 pub impl_kind: ImplItemImplKind,
3397 pub span: Span,
3398}
3399
3400#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ImplItemImplKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ImplItemImplKind::Inherent { vis_span: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Inherent", "vis_span", &__self_0),
ImplItemImplKind::Trait {
defaultness: __self_0, trait_item_def_id: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Trait",
"defaultness", __self_0, "trait_item_def_id", &__self_1),
}
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for ImplItemImplKind {
#[inline]
fn clone(&self) -> ImplItemImplKind {
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Defaultness>;
let _:
::core::clone::AssertParamIsClone<Result<DefId,
ErrorGuaranteed>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ImplItemImplKind { }Copy, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
ImplItemImplKind {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ImplItemImplKind::Inherent { vis_span: ref __binding_0 } =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ImplItemImplKind::Trait {
defaultness: ref __binding_0,
trait_item_def_id: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3401pub enum ImplItemImplKind {
3402 Inherent {
3403 vis_span: Span,
3404 },
3405 Trait {
3406 defaultness: Defaultness,
3407 trait_item_def_id: Result<DefId, ErrorGuaranteed>,
3409 },
3410}
3411
3412impl<'hir> ImplItem<'hir> {
3413 #[inline]
3414 pub fn hir_id(&self) -> HirId {
3415 HirId::make_owner(self.owner_id.def_id)
3417 }
3418
3419 pub fn impl_item_id(&self) -> ImplItemId {
3420 ImplItemId { owner_id: self.owner_id }
3421 }
3422
3423 pub fn vis_span(&self) -> Option<Span> {
3424 match self.impl_kind {
3425 ImplItemImplKind::Trait { .. } => None,
3426 ImplItemImplKind::Inherent { vis_span, .. } => Some(vis_span),
3427 }
3428 }
3429
3430 #[track_caller]
pub fn expect_type(&self) -> &'hir Ty<'hir> {
let ImplItemKind::Type(ty) =
&self.kind else { expect_failed("expect_type", self) };
ty
}expect_methods_self_kind! {
3431 expect_const, (&'hir Ty<'hir>, ConstItemRhs<'hir>), ImplItemKind::Const(ty, rhs), (ty, *rhs);
3432 expect_fn, (&FnSig<'hir>, BodyId), ImplItemKind::Fn(ty, body), (ty, *body);
3433 expect_type, &'hir Ty<'hir>, ImplItemKind::Type(ty), ty;
3434 }
3435}
3436
3437#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ImplItemKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ImplItemKind::Const(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Const",
__self_0, &__self_1),
ImplItemKind::Fn(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Fn",
__self_0, &__self_1),
ImplItemKind::Type(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Type",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ImplItemKind<'hir> {
#[inline]
fn clone(&self) -> ImplItemKind<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<ConstItemRhs<'hir>>;
let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ImplItemKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ImplItemKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ImplItemKind::Const(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ImplItemKind::Fn(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ImplItemKind::Type(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3439pub enum ImplItemKind<'hir> {
3440 Const(&'hir Ty<'hir>, ConstItemRhs<'hir>),
3443 Fn(FnSig<'hir>, BodyId),
3445 Type(&'hir Ty<'hir>),
3447}
3448
3449#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for AssocItemConstraint<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f,
"AssocItemConstraint", "hir_id", &self.hir_id, "ident",
&self.ident, "gen_args", &self.gen_args, "kind", &self.kind,
"span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for AssocItemConstraint<'hir> {
#[inline]
fn clone(&self) -> AssocItemConstraint<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir GenericArgs<'hir>>;
let _:
::core::clone::AssertParamIsClone<AssocItemConstraintKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for AssocItemConstraint<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
AssocItemConstraint<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
AssocItemConstraint {
hir_id: ref __binding_0,
ident: ref __binding_1,
gen_args: ref __binding_2,
kind: ref __binding_3,
span: ref __binding_4 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3460pub struct AssocItemConstraint<'hir> {
3461 #[stable_hash(ignore)]
3462 pub hir_id: HirId,
3463 pub ident: Ident,
3464 pub gen_args: &'hir GenericArgs<'hir>,
3465 pub kind: AssocItemConstraintKind<'hir>,
3466 pub span: Span,
3467}
3468
3469impl<'hir> AssocItemConstraint<'hir> {
3470 pub fn ty(self) -> Option<&'hir Ty<'hir>> {
3472 match self.kind {
3473 AssocItemConstraintKind::Equality { term: Term::Ty(ty) } => Some(ty),
3474 _ => None,
3475 }
3476 }
3477
3478 pub fn ct(self) -> Option<&'hir ConstArg<'hir>> {
3480 match self.kind {
3481 AssocItemConstraintKind::Equality { term: Term::Const(ct) } => Some(ct),
3482 _ => None,
3483 }
3484 }
3485}
3486
3487#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Term<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Term::Ty(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ty",
&__self_0),
Term::Const(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Term<'hir> {
#[inline]
fn clone(&self) -> Term<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Term<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Term<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
Term::Ty(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Term::Const(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3488pub enum Term<'hir> {
3489 Ty(&'hir Ty<'hir>),
3490 Const(&'hir ConstArg<'hir>),
3491}
3492
3493impl<'hir> From<&'hir Ty<'hir>> for Term<'hir> {
3494 fn from(ty: &'hir Ty<'hir>) -> Self {
3495 Term::Ty(ty)
3496 }
3497}
3498
3499impl<'hir> From<&'hir ConstArg<'hir>> for Term<'hir> {
3500 fn from(c: &'hir ConstArg<'hir>) -> Self {
3501 Term::Const(c)
3502 }
3503}
3504
3505#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for AssocItemConstraintKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
AssocItemConstraintKind::Equality { term: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Equality", "term", &__self_0),
AssocItemConstraintKind::Bound { bounds: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Bound",
"bounds", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for AssocItemConstraintKind<'hir> {
#[inline]
fn clone(&self) -> AssocItemConstraintKind<'hir> {
let _: ::core::clone::AssertParamIsClone<Term<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [GenericBound<'hir>]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for AssocItemConstraintKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
AssocItemConstraintKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
AssocItemConstraintKind::Equality { term: ref __binding_0 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AssocItemConstraintKind::Bound { bounds: ref __binding_0 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3507pub enum AssocItemConstraintKind<'hir> {
3508 Equality { term: Term<'hir> },
3515 Bound { bounds: &'hir [GenericBound<'hir>] },
3517}
3518
3519impl<'hir> AssocItemConstraintKind<'hir> {
3520 pub fn descr(&self) -> &'static str {
3521 match self {
3522 AssocItemConstraintKind::Equality { .. } => "binding",
3523 AssocItemConstraintKind::Bound { .. } => "constraint",
3524 }
3525 }
3526}
3527
3528#[derive(#[automatically_derived]
impl ::core::fmt::Debug for AmbigArg {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match *self {}
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for AmbigArg {
#[inline]
fn clone(&self) -> AmbigArg { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for AmbigArg { }Copy, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for AmbigArg {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {}
}
}
};StableHash)]
3532pub enum AmbigArg {}
3533
3534#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
Ty<'hir, Unambig> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "Ty", "hir_id",
&self.hir_id, "span", &self.span, "kind", &&self.kind)
}
}Debug, #[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
Ty<'hir, Unambig> {
#[inline]
fn clone(&self) -> Ty<'hir, Unambig> {
Ty {
hir_id: ::core::clone::Clone::clone(&self.hir_id),
span: ::core::clone::Clone::clone(&self.span),
kind: ::core::clone::Clone::clone(&self.kind),
}
}
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
Ty<'hir, Unambig> {
}Copy, const _: () =
{
impl<'hir, Unambig> ::rustc_data_structures::stable_hash::StableHash
for Ty<'hir, Unambig> where
Unambig: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Ty {
hir_id: ref __binding_0,
span: ref __binding_1,
kind: ref __binding_2 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3539#[repr(C)]
3540pub struct Ty<'hir, Unambig = ()> {
3541 #[stable_hash(ignore)]
3542 pub hir_id: HirId,
3543 pub span: Span,
3544 pub kind: TyKind<'hir, Unambig>,
3545}
3546
3547impl<'hir> Ty<'hir, AmbigArg> {
3548 pub fn as_unambig_ty(&self) -> &Ty<'hir> {
3559 let ptr = self as *const Ty<'hir, AmbigArg> as *const Ty<'hir, ()>;
3562 unsafe { &*ptr }
3563 }
3564}
3565
3566impl<'hir> Ty<'hir> {
3567 pub fn try_as_ambig_ty(&self) -> Option<&Ty<'hir, AmbigArg>> {
3573 if let TyKind::Infer(()) = self.kind {
3574 return None;
3575 }
3576
3577 let ptr = self as *const Ty<'hir> as *const Ty<'hir, AmbigArg>;
3581 Some(unsafe { &*ptr })
3582 }
3583}
3584
3585impl<'hir> Ty<'hir, AmbigArg> {
3586 pub fn peel_refs(&self) -> &Ty<'hir> {
3587 let mut final_ty = self.as_unambig_ty();
3588 while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3589 final_ty = ty;
3590 }
3591 final_ty
3592 }
3593}
3594
3595impl<'hir> Ty<'hir> {
3596 pub fn peel_refs(&self) -> &Self {
3597 let mut final_ty = self;
3598 while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3599 final_ty = ty;
3600 }
3601 final_ty
3602 }
3603
3604 pub fn as_generic_param(&self) -> Option<(DefId, Ident)> {
3606 let TyKind::Path(QPath::Resolved(None, path)) = self.kind else {
3607 return None;
3608 };
3609 let [segment] = &path.segments else {
3610 return None;
3611 };
3612 match path.res {
3613 Res::Def(DefKind::TyParam, def_id) | Res::SelfTyParam { trait_: def_id } => {
3614 Some((def_id, segment.ident))
3615 }
3616 _ => None,
3617 }
3618 }
3619
3620 pub fn find_self_aliases(&self) -> Vec<Span> {
3621 use crate::intravisit::Visitor;
3622 struct MyVisitor(Vec<Span>);
3623 impl<'v> Visitor<'v> for MyVisitor {
3624 fn visit_ty(&mut self, t: &'v Ty<'v, AmbigArg>) {
3625 if #[allow(non_exhaustive_omitted_patterns)] match &t.kind {
TyKind::Path(QPath::Resolved(_, Path {
res: crate::def::Res::SelfTyAlias { .. }, .. })) => true,
_ => false,
}matches!(
3626 &t.kind,
3627 TyKind::Path(QPath::Resolved(
3628 _,
3629 Path { res: crate::def::Res::SelfTyAlias { .. }, .. },
3630 ))
3631 ) {
3632 self.0.push(t.span);
3633 return;
3634 }
3635 crate::intravisit::walk_ty(self, t);
3636 }
3637 }
3638
3639 let mut my_visitor = MyVisitor(::alloc::vec::Vec::new()vec![]);
3640 my_visitor.visit_ty_unambig(self);
3641 my_visitor.0
3642 }
3643
3644 pub fn is_suggestable_infer_ty(&self) -> bool {
3647 fn are_suggestable_generic_args(generic_args: &[GenericArg<'_>]) -> bool {
3648 generic_args.iter().any(|arg| match arg {
3649 GenericArg::Type(ty) => ty.as_unambig_ty().is_suggestable_infer_ty(),
3650 GenericArg::Infer(_) => true,
3651 _ => false,
3652 })
3653 }
3654 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir/src/hir.rs:3654",
"rustc_hir::hir", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir/src/hir.rs"),
::tracing_core::__macro_support::Option::Some(3654u32),
::tracing_core::__macro_support::Option::Some("rustc_hir::hir"),
::tracing_core::field::FieldSet::new(&["self"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&self) as
&dyn Value))])
});
} else { ; }
};debug!(?self);
3655 match &self.kind {
3656 TyKind::Infer(()) => true,
3657 TyKind::Slice(ty) => ty.is_suggestable_infer_ty(),
3658 TyKind::Array(ty, length) => {
3659 ty.is_suggestable_infer_ty() || #[allow(non_exhaustive_omitted_patterns)] match length.kind {
ConstArgKind::Infer(..) => true,
_ => false,
}matches!(length.kind, ConstArgKind::Infer(..))
3660 }
3661 TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
3662 TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),
3663 TyKind::Path(QPath::TypeRelative(ty, segment)) => {
3664 ty.is_suggestable_infer_ty() || are_suggestable_generic_args(segment.args().args)
3665 }
3666 TyKind::Path(QPath::Resolved(ty_opt, Path { segments, .. })) => {
3667 ty_opt.is_some_and(Self::is_suggestable_infer_ty)
3668 || segments
3669 .iter()
3670 .any(|segment| are_suggestable_generic_args(segment.args().args))
3671 }
3672 _ => false,
3673 }
3674 }
3675}
3676
3677#[derive(#[automatically_derived]
impl ::core::marker::Copy for PrimTy { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PrimTy {
#[inline]
fn clone(&self) -> PrimTy {
let _: ::core::clone::AssertParamIsClone<IntTy>;
let _: ::core::clone::AssertParamIsClone<UintTy>;
let _: ::core::clone::AssertParamIsClone<FloatTy>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for PrimTy {
#[inline]
fn eq(&self, other: &PrimTy) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(PrimTy::Int(__self_0), PrimTy::Int(__arg1_0)) =>
__self_0 == __arg1_0,
(PrimTy::Uint(__self_0), PrimTy::Uint(__arg1_0)) =>
__self_0 == __arg1_0,
(PrimTy::Float(__self_0), PrimTy::Float(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for PrimTy {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<IntTy>;
let _: ::core::cmp::AssertParamIsEq<UintTy>;
let _: ::core::cmp::AssertParamIsEq<FloatTy>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for PrimTy {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
PrimTy::Int(ref __binding_0) => { 0usize }
PrimTy::Uint(ref __binding_0) => { 1usize }
PrimTy::Float(ref __binding_0) => { 2usize }
PrimTy::Str => { 3usize }
PrimTy::Bool => { 4usize }
PrimTy::Char => { 5usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
PrimTy::Int(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
PrimTy::Uint(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
PrimTy::Float(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
PrimTy::Str => {}
PrimTy::Bool => {}
PrimTy::Char => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for PrimTy {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
PrimTy::Int(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
PrimTy::Uint(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => {
PrimTy::Float(::rustc_serialize::Decodable::decode(__decoder))
}
3usize => { PrimTy::Str }
4usize => { PrimTy::Bool }
5usize => { PrimTy::Char }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `PrimTy`, expected 0..6, actual {0}",
n));
}
}
}
}
};Decodable, #[automatically_derived]
impl ::core::hash::Hash for PrimTy {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
PrimTy::Int(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
PrimTy::Uint(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
PrimTy::Float(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for PrimTy {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
PrimTy::Int(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Int",
&__self_0),
PrimTy::Uint(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Uint",
&__self_0),
PrimTy::Float(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Float",
&__self_0),
PrimTy::Str => ::core::fmt::Formatter::write_str(f, "Str"),
PrimTy::Bool => ::core::fmt::Formatter::write_str(f, "Bool"),
PrimTy::Char => ::core::fmt::Formatter::write_str(f, "Char"),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for PrimTy {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
PrimTy::Int(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
PrimTy::Uint(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
PrimTy::Float(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
PrimTy::Str => {}
PrimTy::Bool => {}
PrimTy::Char => {}
}
}
}
};StableHash)]
3679pub enum PrimTy {
3680 Int(IntTy),
3681 Uint(UintTy),
3682 Float(FloatTy),
3683 Str,
3684 Bool,
3685 Char,
3686}
3687
3688impl PrimTy {
3689 pub const ALL: [Self; 19] = [
3691 Self::Int(IntTy::I8),
3693 Self::Int(IntTy::I16),
3694 Self::Int(IntTy::I32),
3695 Self::Int(IntTy::I64),
3696 Self::Int(IntTy::I128),
3697 Self::Int(IntTy::Isize),
3698 Self::Uint(UintTy::U8),
3699 Self::Uint(UintTy::U16),
3700 Self::Uint(UintTy::U32),
3701 Self::Uint(UintTy::U64),
3702 Self::Uint(UintTy::U128),
3703 Self::Uint(UintTy::Usize),
3704 Self::Float(FloatTy::F16),
3705 Self::Float(FloatTy::F32),
3706 Self::Float(FloatTy::F64),
3707 Self::Float(FloatTy::F128),
3708 Self::Bool,
3709 Self::Char,
3710 Self::Str,
3711 ];
3712
3713 pub fn name_str(self) -> &'static str {
3717 match self {
3718 PrimTy::Int(i) => i.name_str(),
3719 PrimTy::Uint(u) => u.name_str(),
3720 PrimTy::Float(f) => f.name_str(),
3721 PrimTy::Str => "str",
3722 PrimTy::Bool => "bool",
3723 PrimTy::Char => "char",
3724 }
3725 }
3726
3727 pub fn name(self) -> Symbol {
3728 match self {
3729 PrimTy::Int(i) => i.name(),
3730 PrimTy::Uint(u) => u.name(),
3731 PrimTy::Float(f) => f.name(),
3732 PrimTy::Str => sym::str,
3733 PrimTy::Bool => sym::bool,
3734 PrimTy::Char => sym::char,
3735 }
3736 }
3737
3738 pub fn from_name(name: Symbol) -> Option<Self> {
3741 let ty = match name {
3742 sym::i8 => Self::Int(IntTy::I8),
3744 sym::i16 => Self::Int(IntTy::I16),
3745 sym::i32 => Self::Int(IntTy::I32),
3746 sym::i64 => Self::Int(IntTy::I64),
3747 sym::i128 => Self::Int(IntTy::I128),
3748 sym::isize => Self::Int(IntTy::Isize),
3749 sym::u8 => Self::Uint(UintTy::U8),
3750 sym::u16 => Self::Uint(UintTy::U16),
3751 sym::u32 => Self::Uint(UintTy::U32),
3752 sym::u64 => Self::Uint(UintTy::U64),
3753 sym::u128 => Self::Uint(UintTy::U128),
3754 sym::usize => Self::Uint(UintTy::Usize),
3755 sym::f16 => Self::Float(FloatTy::F16),
3756 sym::f32 => Self::Float(FloatTy::F32),
3757 sym::f64 => Self::Float(FloatTy::F64),
3758 sym::f128 => Self::Float(FloatTy::F128),
3759 sym::bool => Self::Bool,
3760 sym::char => Self::Char,
3761 sym::str => Self::Str,
3762 _ => return None,
3763 };
3764 Some(ty)
3765 }
3766}
3767
3768#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnPtrTy<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "FnPtrTy",
"safety", &self.safety, "abi", &self.abi, "generic_params",
&self.generic_params, "decl", &self.decl, "param_idents",
&&self.param_idents)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnPtrTy<'hir> {
#[inline]
fn clone(&self) -> FnPtrTy<'hir> {
let _: ::core::clone::AssertParamIsClone<Safety>;
let _: ::core::clone::AssertParamIsClone<ExternAbi>;
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir FnDecl<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Option<Ident>]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnPtrTy<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
FnPtrTy<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
FnPtrTy {
safety: ref __binding_0,
abi: ref __binding_1,
generic_params: ref __binding_2,
decl: ref __binding_3,
param_idents: ref __binding_4 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3769pub struct FnPtrTy<'hir> {
3770 pub safety: Safety,
3771 pub abi: ExternAbi,
3772 pub generic_params: &'hir [GenericParam<'hir>],
3773 pub decl: &'hir FnDecl<'hir>,
3774 pub param_idents: &'hir [Option<Ident>],
3777}
3778
3779#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for UnsafeBinderTy<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"UnsafeBinderTy", "generic_params", &self.generic_params,
"inner_ty", &&self.inner_ty)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for UnsafeBinderTy<'hir> {
#[inline]
fn clone(&self) -> UnsafeBinderTy<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for UnsafeBinderTy<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
UnsafeBinderTy<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
UnsafeBinderTy {
generic_params: ref __binding_0, inner_ty: ref __binding_1 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3780pub struct UnsafeBinderTy<'hir> {
3781 pub generic_params: &'hir [GenericParam<'hir>],
3782 pub inner_ty: &'hir Ty<'hir>,
3783}
3784
3785#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for OpaqueTy<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "OpaqueTy",
"hir_id", &self.hir_id, "def_id", &self.def_id, "bounds",
&self.bounds, "origin", &self.origin, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for OpaqueTy<'hir> {
#[inline]
fn clone(&self) -> OpaqueTy<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
let _: ::core::clone::AssertParamIsClone<OpaqueTyOrigin<LocalDefId>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for OpaqueTy<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
OpaqueTy<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
OpaqueTy {
hir_id: ref __binding_0,
def_id: ref __binding_1,
bounds: ref __binding_2,
origin: ref __binding_3,
span: ref __binding_4 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3786pub struct OpaqueTy<'hir> {
3787 #[stable_hash(ignore)]
3788 pub hir_id: HirId,
3789 pub def_id: LocalDefId,
3790 pub bounds: GenericBounds<'hir>,
3791 pub origin: OpaqueTyOrigin<LocalDefId>,
3792 pub span: Span,
3793}
3794
3795#[derive(#[automatically_derived]
impl<T: ::core::fmt::Debug, U: ::core::fmt::Debug> ::core::fmt::Debug for
PreciseCapturingArgKind<T, U> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
PreciseCapturingArgKind::Lifetime(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Lifetime", &__self_0),
PreciseCapturingArgKind::Param(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Param",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<T: ::core::clone::Clone, U: ::core::clone::Clone> ::core::clone::Clone
for PreciseCapturingArgKind<T, U> {
#[inline]
fn clone(&self) -> PreciseCapturingArgKind<T, U> {
match self {
PreciseCapturingArgKind::Lifetime(__self_0) =>
PreciseCapturingArgKind::Lifetime(::core::clone::Clone::clone(__self_0)),
PreciseCapturingArgKind::Param(__self_0) =>
PreciseCapturingArgKind::Param(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]
impl<T: ::core::marker::Copy, U: ::core::marker::Copy> ::core::marker::Copy
for PreciseCapturingArgKind<T, U> {
}Copy, const _: () =
{
impl<T, U> ::rustc_data_structures::stable_hash::StableHash for
PreciseCapturingArgKind<T, U> where
T: ::rustc_data_structures::stable_hash::StableHash,
U: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
PreciseCapturingArgKind::Lifetime(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
PreciseCapturingArgKind::Param(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<T, U, __E: ::rustc_span::SpanEncoder>
::rustc_serialize::Encodable<__E> for
PreciseCapturingArgKind<T, U> where
T: ::rustc_serialize::Encodable<__E>,
U: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
PreciseCapturingArgKind::Lifetime(ref __binding_0) => {
0usize
}
PreciseCapturingArgKind::Param(ref __binding_0) => {
1usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
PreciseCapturingArgKind::Lifetime(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
PreciseCapturingArgKind::Param(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<T, U, __D: ::rustc_span::SpanDecoder>
::rustc_serialize::Decodable<__D> for
PreciseCapturingArgKind<T, U> where
T: ::rustc_serialize::Decodable<__D>,
U: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
PreciseCapturingArgKind::Lifetime(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
PreciseCapturingArgKind::Param(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `PreciseCapturingArgKind`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
3796pub enum PreciseCapturingArgKind<T, U> {
3797 Lifetime(T),
3798 Param(U),
3800}
3801
3802pub type PreciseCapturingArg<'hir> =
3803 PreciseCapturingArgKind<&'hir Lifetime, PreciseCapturingNonLifetimeArg>;
3804
3805impl PreciseCapturingArg<'_> {
3806 pub fn hir_id(self) -> HirId {
3807 match self {
3808 PreciseCapturingArg::Lifetime(lt) => lt.hir_id,
3809 PreciseCapturingArg::Param(param) => param.hir_id,
3810 }
3811 }
3812
3813 pub fn name(self) -> Symbol {
3814 match self {
3815 PreciseCapturingArg::Lifetime(lt) => lt.ident.name,
3816 PreciseCapturingArg::Param(param) => param.ident.name,
3817 }
3818 }
3819}
3820
3821#[derive(#[automatically_derived]
impl ::core::fmt::Debug for PreciseCapturingNonLifetimeArg {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"PreciseCapturingNonLifetimeArg", "hir_id", &self.hir_id, "ident",
&self.ident, "res", &&self.res)
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for PreciseCapturingNonLifetimeArg {
#[inline]
fn clone(&self) -> PreciseCapturingNonLifetimeArg {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<Res>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for PreciseCapturingNonLifetimeArg { }Copy, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
PreciseCapturingNonLifetimeArg {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
PreciseCapturingNonLifetimeArg {
hir_id: ref __binding_0,
ident: ref __binding_1,
res: ref __binding_2 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3826pub struct PreciseCapturingNonLifetimeArg {
3827 #[stable_hash(ignore)]
3828 pub hir_id: HirId,
3829 pub ident: Ident,
3830 pub res: Res,
3831}
3832
3833#[derive(#[automatically_derived]
impl ::core::marker::Copy for RpitContext { }Copy, #[automatically_derived]
impl ::core::clone::Clone for RpitContext {
#[inline]
fn clone(&self) -> RpitContext { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for RpitContext {
#[inline]
fn eq(&self, other: &RpitContext) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for RpitContext {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for RpitContext {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
RpitContext::Trait => "Trait",
RpitContext::TraitImpl => "TraitImpl",
})
}
}Debug)]
3834#[derive(const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for RpitContext
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
RpitContext::Trait => {}
RpitContext::TraitImpl => {}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for RpitContext {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
RpitContext::Trait => { 0usize }
RpitContext::TraitImpl => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
RpitContext::Trait => {}
RpitContext::TraitImpl => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for RpitContext {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { RpitContext::Trait }
1usize => { RpitContext::TraitImpl }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `RpitContext`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
3835pub enum RpitContext {
3836 Trait,
3837 TraitImpl,
3838}
3839
3840#[derive(#[automatically_derived]
impl<D: ::core::marker::Copy> ::core::marker::Copy for OpaqueTyOrigin<D> { }Copy, #[automatically_derived]
impl<D: ::core::clone::Clone> ::core::clone::Clone for OpaqueTyOrigin<D> {
#[inline]
fn clone(&self) -> OpaqueTyOrigin<D> {
match self {
OpaqueTyOrigin::FnReturn {
parent: __self_0, in_trait_or_impl: __self_1 } =>
OpaqueTyOrigin::FnReturn {
parent: ::core::clone::Clone::clone(__self_0),
in_trait_or_impl: ::core::clone::Clone::clone(__self_1),
},
OpaqueTyOrigin::AsyncFn {
parent: __self_0, in_trait_or_impl: __self_1 } =>
OpaqueTyOrigin::AsyncFn {
parent: ::core::clone::Clone::clone(__self_0),
in_trait_or_impl: ::core::clone::Clone::clone(__self_1),
},
OpaqueTyOrigin::TyAlias { parent: __self_0, in_assoc_ty: __self_1
} =>
OpaqueTyOrigin::TyAlias {
parent: ::core::clone::Clone::clone(__self_0),
in_assoc_ty: ::core::clone::Clone::clone(__self_1),
},
}
}
}Clone, #[automatically_derived]
impl<D: ::core::cmp::PartialEq> ::core::cmp::PartialEq for OpaqueTyOrigin<D> {
#[inline]
fn eq(&self, other: &OpaqueTyOrigin<D>) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(OpaqueTyOrigin::FnReturn {
parent: __self_0, in_trait_or_impl: __self_1 },
OpaqueTyOrigin::FnReturn {
parent: __arg1_0, in_trait_or_impl: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(OpaqueTyOrigin::AsyncFn {
parent: __self_0, in_trait_or_impl: __self_1 },
OpaqueTyOrigin::AsyncFn {
parent: __arg1_0, in_trait_or_impl: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(OpaqueTyOrigin::TyAlias {
parent: __self_0, in_assoc_ty: __self_1 },
OpaqueTyOrigin::TyAlias {
parent: __arg1_0, in_assoc_ty: __arg1_1 }) =>
__self_1 == __arg1_1 && __self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl<D: ::core::cmp::Eq> ::core::cmp::Eq for OpaqueTyOrigin<D> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<D>;
let _: ::core::cmp::AssertParamIsEq<Option<RpitContext>>;
let _: ::core::cmp::AssertParamIsEq<Option<RpitContext>>;
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]
impl<D: ::core::fmt::Debug> ::core::fmt::Debug for OpaqueTyOrigin<D> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
OpaqueTyOrigin::FnReturn {
parent: __self_0, in_trait_or_impl: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"FnReturn", "parent", __self_0, "in_trait_or_impl",
&__self_1),
OpaqueTyOrigin::AsyncFn {
parent: __self_0, in_trait_or_impl: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"AsyncFn", "parent", __self_0, "in_trait_or_impl",
&__self_1),
OpaqueTyOrigin::TyAlias { parent: __self_0, in_assoc_ty: __self_1
} =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"TyAlias", "parent", __self_0, "in_assoc_ty", &__self_1),
}
}
}Debug)]
3842#[derive(const _: () =
{
impl<D> ::rustc_data_structures::stable_hash::StableHash for
OpaqueTyOrigin<D> where
D: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
OpaqueTyOrigin::FnReturn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
OpaqueTyOrigin::AsyncFn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
OpaqueTyOrigin::TyAlias {
parent: ref __binding_0, in_assoc_ty: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<D, __E: ::rustc_span::SpanEncoder>
::rustc_serialize::Encodable<__E> for OpaqueTyOrigin<D> where
D: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
OpaqueTyOrigin::FnReturn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
0usize
}
OpaqueTyOrigin::AsyncFn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
1usize
}
OpaqueTyOrigin::TyAlias {
parent: ref __binding_0, in_assoc_ty: ref __binding_1 } => {
2usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
OpaqueTyOrigin::FnReturn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
OpaqueTyOrigin::AsyncFn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
OpaqueTyOrigin::TyAlias {
parent: ref __binding_0, in_assoc_ty: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<D, __D: ::rustc_span::SpanDecoder>
::rustc_serialize::Decodable<__D> for OpaqueTyOrigin<D> where
D: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
OpaqueTyOrigin::FnReturn {
parent: ::rustc_serialize::Decodable::decode(__decoder),
in_trait_or_impl: ::rustc_serialize::Decodable::decode(__decoder),
}
}
1usize => {
OpaqueTyOrigin::AsyncFn {
parent: ::rustc_serialize::Decodable::decode(__decoder),
in_trait_or_impl: ::rustc_serialize::Decodable::decode(__decoder),
}
}
2usize => {
OpaqueTyOrigin::TyAlias {
parent: ::rustc_serialize::Decodable::decode(__decoder),
in_assoc_ty: ::rustc_serialize::Decodable::decode(__decoder),
}
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `OpaqueTyOrigin`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
3843pub enum OpaqueTyOrigin<D> {
3844 FnReturn {
3846 parent: D,
3848 in_trait_or_impl: Option<RpitContext>,
3850 },
3851 AsyncFn {
3853 parent: D,
3855 in_trait_or_impl: Option<RpitContext>,
3857 },
3858 TyAlias {
3860 parent: D,
3862 in_assoc_ty: bool,
3864 },
3865}
3866
3867#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DelegationSelfTyPropagationKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
DelegationSelfTyPropagationKind::SelfTy(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "SelfTy",
&__self_0),
DelegationSelfTyPropagationKind::SelfParam =>
::core::fmt::Formatter::write_str(f, "SelfParam"),
}
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for DelegationSelfTyPropagationKind {
#[inline]
fn clone(&self) -> DelegationSelfTyPropagationKind {
let _: ::core::clone::AssertParamIsClone<HirId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DelegationSelfTyPropagationKind { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for DelegationSelfTyPropagationKind {
#[inline]
fn eq(&self, other: &DelegationSelfTyPropagationKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(DelegationSelfTyPropagationKind::SelfTy(__self_0),
DelegationSelfTyPropagationKind::SelfTy(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DelegationSelfTyPropagationKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<HirId>;
}
}Eq, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
DelegationSelfTyPropagationKind {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
DelegationSelfTyPropagationKind::SelfTy(ref __binding_0) =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
}
DelegationSelfTyPropagationKind::SelfParam => {}
}
}
}
};StableHash)]
3868pub enum DelegationSelfTyPropagationKind {
3869 SelfTy(HirId ),
3872 SelfParam,
3875}
3876
3877#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DelegationInfo {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["call_expr_id", "call_path_res", "child_seg_id",
"parent_seg_id_for_sig", "child_seg_id_for_sig",
"self_ty_propagation_kind", "group_id"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.call_expr_id, &self.call_path_res, &self.child_seg_id,
&self.parent_seg_id_for_sig, &self.child_seg_id_for_sig,
&self.self_ty_propagation_kind, &&self.group_id];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"DelegationInfo", names, values)
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for DelegationInfo {
#[inline]
fn clone(&self) -> DelegationInfo {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Option<DefId>>;
let _: ::core::clone::AssertParamIsClone<Option<HirId>>;
let _: ::core::clone::AssertParamIsClone<Option<HirId>>;
let _:
::core::clone::AssertParamIsClone<Option<DelegationSelfTyPropagationKind>>;
let _: ::core::clone::AssertParamIsClone<Option<(LocalExpnId, bool)>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DelegationInfo { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for DelegationInfo {
#[inline]
fn eq(&self, other: &DelegationInfo) -> bool {
self.call_expr_id == other.call_expr_id &&
self.call_path_res == other.call_path_res &&
self.child_seg_id == other.child_seg_id &&
self.parent_seg_id_for_sig == other.parent_seg_id_for_sig &&
self.child_seg_id_for_sig == other.child_seg_id_for_sig &&
self.self_ty_propagation_kind ==
other.self_ty_propagation_kind &&
self.group_id == other.group_id
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DelegationInfo {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<HirId>;
let _: ::core::cmp::AssertParamIsEq<Option<DefId>>;
let _: ::core::cmp::AssertParamIsEq<Option<HirId>>;
let _: ::core::cmp::AssertParamIsEq<Option<HirId>>;
let _:
::core::cmp::AssertParamIsEq<Option<DelegationSelfTyPropagationKind>>;
let _: ::core::cmp::AssertParamIsEq<Option<(LocalExpnId, bool)>>;
}
}Eq, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
DelegationInfo {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
DelegationInfo {
call_expr_id: ref __binding_0,
call_path_res: ref __binding_1,
child_seg_id: ref __binding_2,
parent_seg_id_for_sig: ref __binding_3,
child_seg_id_for_sig: ref __binding_4,
self_ty_propagation_kind: ref __binding_5,
group_id: ref __binding_6 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
{ __binding_6.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3878pub struct DelegationInfo {
3879 pub call_expr_id: HirId,
3880 pub call_path_res: Option<DefId>,
3881
3882 pub child_seg_id: HirId,
3885
3886 pub parent_seg_id_for_sig: Option<HirId>,
3892 pub child_seg_id_for_sig: Option<HirId>,
3893
3894 pub self_ty_propagation_kind: Option<DelegationSelfTyPropagationKind>,
3895 pub group_id: Option<(LocalExpnId, bool )>,
3896}
3897
3898#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InferDelegationSig<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
InferDelegationSig::Input(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Input",
&__self_0),
InferDelegationSig::Output(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Output",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InferDelegationSig<'hir> {
#[inline]
fn clone(&self) -> InferDelegationSig<'hir> {
let _: ::core::clone::AssertParamIsClone<usize>;
let _: ::core::clone::AssertParamIsClone<&'hir DelegationInfo>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InferDelegationSig<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::cmp::PartialEq for InferDelegationSig<'hir> {
#[inline]
fn eq(&self, other: &InferDelegationSig<'hir>) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(InferDelegationSig::Input(__self_0),
InferDelegationSig::Input(__arg1_0)) =>
__self_0 == __arg1_0,
(InferDelegationSig::Output(__self_0),
InferDelegationSig::Output(__arg1_0)) =>
__self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl<'hir> ::core::cmp::Eq for InferDelegationSig<'hir> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<usize>;
let _: ::core::cmp::AssertParamIsEq<&'hir DelegationInfo>;
}
}Eq, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
InferDelegationSig<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
InferDelegationSig::Input(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
InferDelegationSig::Output(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3899pub enum InferDelegationSig<'hir> {
3900 Input(usize),
3901 Output(&'hir DelegationInfo),
3903}
3904
3905#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InferDelegation<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
InferDelegation::DefId(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "DefId",
&__self_0),
InferDelegation::Sig(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Sig",
__self_0, &__self_1),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InferDelegation<'hir> {
#[inline]
fn clone(&self) -> InferDelegation<'hir> {
let _: ::core::clone::AssertParamIsClone<DefId>;
let _: ::core::clone::AssertParamIsClone<InferDelegationSig<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InferDelegation<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::cmp::PartialEq for InferDelegation<'hir> {
#[inline]
fn eq(&self, other: &InferDelegation<'hir>) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(InferDelegation::DefId(__self_0),
InferDelegation::DefId(__arg1_0)) => __self_0 == __arg1_0,
(InferDelegation::Sig(__self_0, __self_1),
InferDelegation::Sig(__arg1_0, __arg1_1)) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl<'hir> ::core::cmp::Eq for InferDelegation<'hir> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<DefId>;
let _: ::core::cmp::AssertParamIsEq<InferDelegationSig<'hir>>;
}
}Eq, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
InferDelegation<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
InferDelegation::DefId(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
InferDelegation::Sig(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3906pub enum InferDelegation<'hir> {
3907 DefId(DefId),
3910 Sig(DefId, InferDelegationSig<'hir>),
3912}
3913
3914#[repr(u8, C)]
3920#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
TyKind<'hir, Unambig> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TyKind::InferDelegation(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"InferDelegation", &__self_0),
TyKind::Slice(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Slice",
&__self_0),
TyKind::Array(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Array",
__self_0, &__self_1),
TyKind::Ptr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ptr",
&__self_0),
TyKind::Ref(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Ref",
__self_0, &__self_1),
TyKind::FnPtr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "FnPtr",
&__self_0),
TyKind::UnsafeBinder(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"UnsafeBinder", &__self_0),
TyKind::Never => ::core::fmt::Formatter::write_str(f, "Never"),
TyKind::Tup(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tup",
&__self_0),
TyKind::Path(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
&__self_0),
TyKind::OpaqueDef(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"OpaqueDef", &__self_0),
TyKind::TraitAscription(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TraitAscription", &__self_0),
TyKind::TraitObject(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"TraitObject", __self_0, &__self_1),
TyKind::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
TyKind::Pat(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Pat",
__self_0, &__self_1),
TyKind::FieldOf(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"FieldOf", __self_0, &__self_1),
TyKind::Infer(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
TyKind<'hir, Unambig> {
#[inline]
fn clone(&self) -> TyKind<'hir, Unambig> {
match self {
TyKind::InferDelegation(__self_0) =>
TyKind::InferDelegation(::core::clone::Clone::clone(__self_0)),
TyKind::Slice(__self_0) =>
TyKind::Slice(::core::clone::Clone::clone(__self_0)),
TyKind::Array(__self_0, __self_1) =>
TyKind::Array(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::Ptr(__self_0) =>
TyKind::Ptr(::core::clone::Clone::clone(__self_0)),
TyKind::Ref(__self_0, __self_1) =>
TyKind::Ref(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::FnPtr(__self_0) =>
TyKind::FnPtr(::core::clone::Clone::clone(__self_0)),
TyKind::UnsafeBinder(__self_0) =>
TyKind::UnsafeBinder(::core::clone::Clone::clone(__self_0)),
TyKind::Never => TyKind::Never,
TyKind::Tup(__self_0) =>
TyKind::Tup(::core::clone::Clone::clone(__self_0)),
TyKind::Path(__self_0) =>
TyKind::Path(::core::clone::Clone::clone(__self_0)),
TyKind::OpaqueDef(__self_0) =>
TyKind::OpaqueDef(::core::clone::Clone::clone(__self_0)),
TyKind::TraitAscription(__self_0) =>
TyKind::TraitAscription(::core::clone::Clone::clone(__self_0)),
TyKind::TraitObject(__self_0, __self_1) =>
TyKind::TraitObject(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::Err(__self_0) =>
TyKind::Err(::core::clone::Clone::clone(__self_0)),
TyKind::Pat(__self_0, __self_1) =>
TyKind::Pat(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::FieldOf(__self_0, __self_1) =>
TyKind::FieldOf(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::Infer(__self_0) =>
TyKind::Infer(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
TyKind<'hir, Unambig> {
}Copy, const _: () =
{
impl<'hir, Unambig> ::rustc_data_structures::stable_hash::StableHash
for TyKind<'hir, Unambig> where
Unambig: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
TyKind::InferDelegation(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Slice(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Array(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Ptr(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Ref(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::FnPtr(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::UnsafeBinder(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Never => {}
TyKind::Tup(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Path(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::OpaqueDef(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::TraitAscription(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::TraitObject(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Err(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Pat(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::FieldOf(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Infer(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3921pub enum TyKind<'hir, Unambig = ()> {
3922 InferDelegation(InferDelegation<'hir>),
3924 Slice(&'hir Ty<'hir>),
3926 Array(&'hir Ty<'hir>, &'hir ConstArg<'hir>),
3928 Ptr(MutTy<'hir>),
3930 Ref(&'hir Lifetime, MutTy<'hir>),
3932 FnPtr(&'hir FnPtrTy<'hir>),
3934 UnsafeBinder(&'hir UnsafeBinderTy<'hir>),
3936 Never,
3938 Tup(&'hir [Ty<'hir>]),
3940 Path(QPath<'hir>),
3945 OpaqueDef(&'hir OpaqueTy<'hir>),
3947 TraitAscription(GenericBounds<'hir>),
3949 TraitObject(&'hir [PolyTraitRef<'hir>], TaggedRef<'hir, Lifetime, TraitObjectSyntax>),
3955 Err(rustc_span::ErrorGuaranteed),
3957 Pat(&'hir Ty<'hir>, &'hir TyPat<'hir>),
3959 FieldOf(&'hir Ty<'hir>, &'hir TyFieldPath),
3963 Infer(Unambig),
3969}
3970
3971#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InlineAsmOperand<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
InlineAsmOperand::In { reg: __self_0, expr: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "In",
"reg", __self_0, "expr", &__self_1),
InlineAsmOperand::Out {
reg: __self_0, late: __self_1, expr: __self_2 } =>
::core::fmt::Formatter::debug_struct_field3_finish(f, "Out",
"reg", __self_0, "late", __self_1, "expr", &__self_2),
InlineAsmOperand::InOut {
reg: __self_0, late: __self_1, expr: __self_2 } =>
::core::fmt::Formatter::debug_struct_field3_finish(f, "InOut",
"reg", __self_0, "late", __self_1, "expr", &__self_2),
InlineAsmOperand::SplitInOut {
reg: __self_0,
late: __self_1,
in_expr: __self_2,
out_expr: __self_3 } =>
::core::fmt::Formatter::debug_struct_field4_finish(f,
"SplitInOut", "reg", __self_0, "late", __self_1, "in_expr",
__self_2, "out_expr", &__self_3),
InlineAsmOperand::Const { anon_const: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Const",
"anon_const", &__self_0),
InlineAsmOperand::SymFn { expr: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "SymFn",
"expr", &__self_0),
InlineAsmOperand::SymStatic { path: __self_0, def_id: __self_1 }
=>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"SymStatic", "path", __self_0, "def_id", &__self_1),
InlineAsmOperand::Label { block: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Label",
"block", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InlineAsmOperand<'hir> {
#[inline]
fn clone(&self) -> InlineAsmOperand<'hir> {
let _: ::core::clone::AssertParamIsClone<InlineAsmRegOrRegClass>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<ConstBlock>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
let _: ::core::clone::AssertParamIsClone<DefId>;
let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InlineAsmOperand<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
InlineAsmOperand<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
InlineAsmOperand::In {
reg: ref __binding_0, expr: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
InlineAsmOperand::Out {
reg: ref __binding_0,
late: ref __binding_1,
expr: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
InlineAsmOperand::InOut {
reg: ref __binding_0,
late: ref __binding_1,
expr: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
InlineAsmOperand::SplitInOut {
reg: ref __binding_0,
late: ref __binding_1,
in_expr: ref __binding_2,
out_expr: ref __binding_3 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
InlineAsmOperand::Const { anon_const: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
InlineAsmOperand::SymFn { expr: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
InlineAsmOperand::SymStatic {
path: ref __binding_0, def_id: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
InlineAsmOperand::Label { block: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
3972pub enum InlineAsmOperand<'hir> {
3973 In {
3974 reg: InlineAsmRegOrRegClass,
3975 expr: &'hir Expr<'hir>,
3976 },
3977 Out {
3978 reg: InlineAsmRegOrRegClass,
3979 late: bool,
3980 expr: Option<&'hir Expr<'hir>>,
3981 },
3982 InOut {
3983 reg: InlineAsmRegOrRegClass,
3984 late: bool,
3985 expr: &'hir Expr<'hir>,
3986 },
3987 SplitInOut {
3988 reg: InlineAsmRegOrRegClass,
3989 late: bool,
3990 in_expr: &'hir Expr<'hir>,
3991 out_expr: Option<&'hir Expr<'hir>>,
3992 },
3993 Const {
3994 anon_const: ConstBlock,
3995 },
3996 SymFn {
3997 expr: &'hir Expr<'hir>,
3998 },
3999 SymStatic {
4000 path: QPath<'hir>,
4001 def_id: DefId,
4002 },
4003 Label {
4004 block: &'hir Block<'hir>,
4005 },
4006}
4007
4008impl<'hir> InlineAsmOperand<'hir> {
4009 pub fn reg(&self) -> Option<InlineAsmRegOrRegClass> {
4010 match *self {
4011 Self::In { reg, .. }
4012 | Self::Out { reg, .. }
4013 | Self::InOut { reg, .. }
4014 | Self::SplitInOut { reg, .. } => Some(reg),
4015 Self::Const { .. }
4016 | Self::SymFn { .. }
4017 | Self::SymStatic { .. }
4018 | Self::Label { .. } => None,
4019 }
4020 }
4021
4022 pub fn is_clobber(&self) -> bool {
4023 #[allow(non_exhaustive_omitted_patterns)] match self {
InlineAsmOperand::Out {
reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None } => true,
_ => false,
}matches!(
4024 self,
4025 InlineAsmOperand::Out { reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None }
4026 )
4027 }
4028}
4029
4030#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InlineAsm<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["asm_macro", "template", "template_strs", "operands", "options",
"line_spans"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.asm_macro, &self.template, &self.template_strs,
&self.operands, &self.options, &&self.line_spans];
::core::fmt::Formatter::debug_struct_fields_finish(f, "InlineAsm",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InlineAsm<'hir> {
#[inline]
fn clone(&self) -> InlineAsm<'hir> {
let _: ::core::clone::AssertParamIsClone<ast::AsmMacro>;
let _:
::core::clone::AssertParamIsClone<&'hir [InlineAsmTemplatePiece]>;
let _:
::core::clone::AssertParamIsClone<&'hir [(Symbol,
Option<Symbol>, Span)]>;
let _:
::core::clone::AssertParamIsClone<&'hir [(InlineAsmOperand<'hir>,
Span)]>;
let _: ::core::clone::AssertParamIsClone<InlineAsmOptions>;
let _: ::core::clone::AssertParamIsClone<&'hir [Span]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InlineAsm<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
InlineAsm<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
InlineAsm {
asm_macro: ref __binding_0,
template: ref __binding_1,
template_strs: ref __binding_2,
operands: ref __binding_3,
options: ref __binding_4,
line_spans: ref __binding_5 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4031pub struct InlineAsm<'hir> {
4032 pub asm_macro: ast::AsmMacro,
4033 pub template: &'hir [InlineAsmTemplatePiece],
4034 pub template_strs: &'hir [(Symbol, Option<Symbol>, Span)],
4035 pub operands: &'hir [(InlineAsmOperand<'hir>, Span)],
4036 pub options: InlineAsmOptions,
4037 pub line_spans: &'hir [Span],
4038}
4039
4040impl InlineAsm<'_> {
4041 pub fn contains_label(&self) -> bool {
4042 self.operands.iter().any(|x| #[allow(non_exhaustive_omitted_patterns)] match x.0 {
InlineAsmOperand::Label { .. } => true,
_ => false,
}matches!(x.0, InlineAsmOperand::Label { .. }))
4043 }
4044}
4045
4046#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Param<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "Param",
"hir_id", &self.hir_id, "pat", &self.pat, "ty_span",
&self.ty_span, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Param<'hir> {
#[inline]
fn clone(&self) -> Param<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Param<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Param<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Param {
hir_id: ref __binding_0,
pat: ref __binding_1,
ty_span: ref __binding_2,
span: ref __binding_3 } => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4048pub struct Param<'hir> {
4049 #[stable_hash(ignore)]
4050 pub hir_id: HirId,
4051 pub pat: &'hir Pat<'hir>,
4052 pub ty_span: Span,
4053 pub span: Span,
4054}
4055
4056#[derive(#[automatically_derived]
impl ::core::fmt::Debug for SplattedArgIndexError {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
SplattedArgIndexError::InvalidIndex { splatted_arg_index: __self_0
} =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"InvalidIndex", "splatted_arg_index", &__self_0),
SplattedArgIndexError::OutOfBounds {
splatted_arg_index: __self_0, args_len: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"OutOfBounds", "splatted_arg_index", __self_0, "args_len",
&__self_1),
}
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for SplattedArgIndexError {
#[inline]
fn clone(&self) -> SplattedArgIndexError {
let _: ::core::clone::AssertParamIsClone<u8>;
let _: ::core::clone::AssertParamIsClone<u16>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for SplattedArgIndexError { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for SplattedArgIndexError {
#[inline]
fn eq(&self, other: &SplattedArgIndexError) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(SplattedArgIndexError::InvalidIndex {
splatted_arg_index: __self_0 },
SplattedArgIndexError::InvalidIndex {
splatted_arg_index: __arg1_0 }) => __self_0 == __arg1_0,
(SplattedArgIndexError::OutOfBounds {
splatted_arg_index: __self_0, args_len: __self_1 },
SplattedArgIndexError::OutOfBounds {
splatted_arg_index: __arg1_0, args_len: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for SplattedArgIndexError {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u8>;
let _: ::core::cmp::AssertParamIsEq<u16>;
}
}Eq)]
4058pub enum SplattedArgIndexError {
4059 InvalidIndex { splatted_arg_index: u8 },
4063
4064 OutOfBounds { splatted_arg_index: u8, args_len: u16 },
4066}
4067
4068#[derive(#[automatically_derived]
impl ::core::marker::Copy for FnDeclFlags { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FnDeclFlags {
#[inline]
fn clone(&self) -> FnDeclFlags {
let _: ::core::clone::AssertParamIsClone<u8>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for FnDeclFlags {
#[inline]
fn eq(&self, other: &FnDeclFlags) -> bool {
self.flags == other.flags && self.splatted == other.splatted
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FnDeclFlags {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u8>;
}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for FnDeclFlags {
#[inline]
fn partial_cmp(&self, other: &FnDeclFlags)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for FnDeclFlags {
#[inline]
fn cmp(&self, other: &FnDeclFlags) -> ::core::cmp::Ordering {
match ::core::cmp::Ord::cmp(&self.flags, &other.flags) {
::core::cmp::Ordering::Equal =>
::core::cmp::Ord::cmp(&self.splatted, &other.splatted),
cmp => cmp,
}
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for FnDeclFlags {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.flags, state);
::core::hash::Hash::hash(&self.splatted, state)
}
}Hash)]
4070#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for FnDeclFlags {
fn encode(&self, __encoder: &mut __E) {
match *self {
FnDeclFlags {
flags: ref __binding_0, splatted: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for FnDeclFlags {
fn decode(__decoder: &mut __D) -> Self {
FnDeclFlags {
flags: ::rustc_serialize::Decodable::decode(__decoder),
splatted: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for FnDeclFlags
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
FnDeclFlags {
flags: ref __binding_0, splatted: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4071pub struct FnDeclFlags {
4072 flags: u8,
4074
4075 splatted: u8,
4079}
4080
4081impl fmt::Debug for FnDeclFlags {
4082 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4083 let mut f = f.debug_tuple("FnDeclFlags");
4084 f.field(&::alloc::__export::must_use({
::alloc::fmt::format(format_args!("ImplicitSelfKind({0:?})",
self.implicit_self()))
})format!("ImplicitSelfKind({:?})", self.implicit_self()));
4085
4086 if self.lifetime_elision_allowed() {
4087 f.field(&"LifetimeElisionAllowed");
4088 } else {
4089 f.field(&"NoLifetimeElision");
4090 }
4091
4092 if self.c_variadic() {
4093 f.field(&"CVariadic");
4094 }
4095
4096 if let Some(index) = self.splatted() {
4097 f.field(&::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Splatted({0})", index))
})format!("Splatted({})", index));
4098 }
4099
4100 f.finish()
4101 }
4102}
4103
4104impl FnDeclFlags {
4105 const IMPLICIT_SELF_MASK: u8 = 0b111;
4107
4108 const C_VARIADIC_FLAG: u8 = 1 << 3;
4110
4111 const LIFETIME_ELISION_ALLOWED_FLAG: u8 = 1 << 4;
4113
4114 const NO_SPLATTED_ARG_INDEX: u8 = u8::MAX;
4117
4118 pub fn default() -> Self {
4123 Self { flags: 0, splatted: 0 }
4124 .set_implicit_self(ImplicitSelfKind::None)
4125 .set_lifetime_elision_allowed(false)
4126 .set_c_variadic(false)
4127 .set_no_splatted_args()
4128 }
4129
4130 #[must_use = "this method does not modify the receiver"]
4132 pub fn set_implicit_self(mut self, implicit_self: ImplicitSelfKind) -> Self {
4133 self.flags &= !Self::IMPLICIT_SELF_MASK;
4134
4135 match implicit_self {
4136 ImplicitSelfKind::None => self.flags |= 0,
4137 ImplicitSelfKind::Imm => self.flags |= 1,
4138 ImplicitSelfKind::Mut => self.flags |= 2,
4139 ImplicitSelfKind::RefImm => self.flags |= 3,
4140 ImplicitSelfKind::RefMut => self.flags |= 4,
4141 }
4142
4143 self
4144 }
4145
4146 #[must_use = "this method does not modify the receiver"]
4148 pub fn set_c_variadic(mut self, c_variadic: bool) -> Self {
4149 if c_variadic {
4150 self.flags |= Self::C_VARIADIC_FLAG;
4151 } else {
4152 self.flags &= !Self::C_VARIADIC_FLAG;
4153 }
4154
4155 self
4156 }
4157
4158 #[must_use = "this method does not modify the receiver"]
4160 pub fn set_lifetime_elision_allowed(mut self, allowed: bool) -> Self {
4161 if allowed {
4162 self.flags |= Self::LIFETIME_ELISION_ALLOWED_FLAG;
4163 } else {
4164 self.flags &= !Self::LIFETIME_ELISION_ALLOWED_FLAG;
4165 }
4166
4167 self
4168 }
4169
4170 #[must_use = "this method does not modify the receiver"]
4173 pub fn set_splatted(
4174 mut self,
4175 splatted: Option<u8>,
4176 args_len: usize,
4177 ) -> Result<Self, SplattedArgIndexError> {
4178 if let Some(splatted_arg_index) = splatted {
4179 if splatted_arg_index == Self::NO_SPLATTED_ARG_INDEX {
4180 return Err(SplattedArgIndexError::InvalidIndex { splatted_arg_index });
4183 } else if usize::from(splatted_arg_index) >= args_len {
4184 return Err(SplattedArgIndexError::OutOfBounds {
4185 splatted_arg_index,
4186 args_len: args_len as u16,
4187 });
4188 }
4189
4190 self.splatted = splatted_arg_index;
4191 } else {
4192 self.splatted = Self::NO_SPLATTED_ARG_INDEX;
4193 }
4194
4195 Ok(self)
4196 }
4197
4198 #[must_use = "this method does not modify the receiver"]
4200 pub fn set_no_splatted_args(mut self) -> Self {
4201 self.splatted = Self::NO_SPLATTED_ARG_INDEX;
4202
4203 self
4204 }
4205
4206 pub fn implicit_self(self) -> ImplicitSelfKind {
4208 match self.flags & Self::IMPLICIT_SELF_MASK {
4209 0 => ImplicitSelfKind::None,
4210 1 => ImplicitSelfKind::Imm,
4211 2 => ImplicitSelfKind::Mut,
4212 3 => ImplicitSelfKind::RefImm,
4213 4 => ImplicitSelfKind::RefMut,
4214 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4215 }
4216 }
4217
4218 pub fn c_variadic(self) -> bool {
4220 self.flags & Self::C_VARIADIC_FLAG != 0
4221 }
4222
4223 pub fn lifetime_elision_allowed(self) -> bool {
4225 self.flags & Self::LIFETIME_ELISION_ALLOWED_FLAG != 0
4226 }
4227
4228 pub fn splatted(self) -> Option<u8> {
4230 if self.splatted == Self::NO_SPLATTED_ARG_INDEX { None } else { Some(self.splatted) }
4231 }
4232}
4233
4234#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnDecl<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "FnDecl",
"inputs", &self.inputs, "output", &self.output, "fn_decl_kind",
&&self.fn_decl_kind)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnDecl<'hir> {
#[inline]
fn clone(&self) -> FnDecl<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [Ty<'hir>]>;
let _: ::core::clone::AssertParamIsClone<FnRetTy<'hir>>;
let _: ::core::clone::AssertParamIsClone<FnDeclFlags>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnDecl<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
FnDecl<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
FnDecl {
inputs: ref __binding_0,
output: ref __binding_1,
fn_decl_kind: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4236pub struct FnDecl<'hir> {
4237 pub inputs: &'hir [Ty<'hir>],
4241 pub output: FnRetTy<'hir>,
4242 pub fn_decl_kind: FnDeclFlags,
4244}
4245
4246impl<'hir> FnDecl<'hir> {
4247 pub fn opt_delegation_sig_id(&self) -> Option<DefId> {
4248 if let FnRetTy::Return(ty) = self.output
4249 && let TyKind::InferDelegation(InferDelegation::Sig(sig_id, _)) = ty.kind
4250 {
4251 return Some(sig_id);
4252 }
4253 None
4254 }
4255
4256 pub fn opt_delegation_info(&self) -> Option<&'hir DelegationInfo> {
4257 if let FnRetTy::Return(ty) = self.output
4258 && let TyKind::InferDelegation(InferDelegation::Sig(_, kind)) = ty.kind
4259 && let InferDelegationSig::Output(generics) = kind
4260 {
4261 return Some(generics);
4262 }
4263
4264 None
4265 }
4266
4267 pub fn implicit_self(&self) -> ImplicitSelfKind {
4268 self.fn_decl_kind.implicit_self()
4269 }
4270
4271 pub fn c_variadic(&self) -> bool {
4272 self.fn_decl_kind.c_variadic()
4273 }
4274
4275 pub fn lifetime_elision_allowed(&self) -> bool {
4276 self.fn_decl_kind.lifetime_elision_allowed()
4277 }
4278
4279 pub fn splatted(&self) -> Option<u8> {
4280 self.fn_decl_kind.splatted()
4281 }
4282
4283 pub fn dummy(span: Span) -> Self {
4284 Self {
4285 inputs: &[],
4286 output: FnRetTy::DefaultReturn(span),
4287 fn_decl_kind: FnDeclFlags::default().set_lifetime_elision_allowed(true),
4288 }
4289 }
4290}
4291
4292#[derive(#[automatically_derived]
impl ::core::marker::Copy for ImplicitSelfKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ImplicitSelfKind {
#[inline]
fn clone(&self) -> ImplicitSelfKind { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ImplicitSelfKind {
#[inline]
fn eq(&self, other: &ImplicitSelfKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplicitSelfKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ImplicitSelfKind {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
ImplicitSelfKind::Imm => { 0usize }
ImplicitSelfKind::Mut => { 1usize }
ImplicitSelfKind::RefImm => { 2usize }
ImplicitSelfKind::RefMut => { 3usize }
ImplicitSelfKind::None => { 4usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
ImplicitSelfKind::Imm => {}
ImplicitSelfKind::Mut => {}
ImplicitSelfKind::RefImm => {}
ImplicitSelfKind::RefMut => {}
ImplicitSelfKind::None => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ImplicitSelfKind {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { ImplicitSelfKind::Imm }
1usize => { ImplicitSelfKind::Mut }
2usize => { ImplicitSelfKind::RefImm }
3usize => { ImplicitSelfKind::RefMut }
4usize => { ImplicitSelfKind::None }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ImplicitSelfKind`, expected 0..5, actual {0}",
n));
}
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ImplicitSelfKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
ImplicitSelfKind::Imm => "Imm",
ImplicitSelfKind::Mut => "Mut",
ImplicitSelfKind::RefImm => "RefImm",
ImplicitSelfKind::RefMut => "RefMut",
ImplicitSelfKind::None => "None",
})
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
ImplicitSelfKind {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ImplicitSelfKind::Imm => {}
ImplicitSelfKind::Mut => {}
ImplicitSelfKind::RefImm => {}
ImplicitSelfKind::RefMut => {}
ImplicitSelfKind::None => {}
}
}
}
};StableHash)]
4294pub enum ImplicitSelfKind {
4295 Imm,
4297 Mut,
4299 RefImm,
4301 RefMut,
4303 None,
4306}
4307
4308impl ImplicitSelfKind {
4309 pub fn has_implicit_self(&self) -> bool {
4311 !#[allow(non_exhaustive_omitted_patterns)] match *self {
ImplicitSelfKind::None => true,
_ => false,
}matches!(*self, ImplicitSelfKind::None)
4312 }
4313}
4314
4315#[derive(#[automatically_derived]
impl ::core::marker::Copy for IsAsync { }Copy, #[automatically_derived]
impl ::core::clone::Clone for IsAsync {
#[inline]
fn clone(&self) -> IsAsync {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for IsAsync {
#[inline]
fn eq(&self, other: &IsAsync) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(IsAsync::Async(__self_0), IsAsync::Async(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for IsAsync {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Span>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for IsAsync {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
IsAsync::Async(ref __binding_0) => { 0usize }
IsAsync::NotAsync => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
IsAsync::Async(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
IsAsync::NotAsync => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for IsAsync {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
IsAsync::Async(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => { IsAsync::NotAsync }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `IsAsync`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for IsAsync {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
IsAsync::Async(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Async",
&__self_0),
IsAsync::NotAsync =>
::core::fmt::Formatter::write_str(f, "NotAsync"),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for IsAsync {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
IsAsync::Async(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
IsAsync::NotAsync => {}
}
}
}
};StableHash)]
4316pub enum IsAsync {
4317 Async(Span),
4318 NotAsync,
4319}
4320
4321impl IsAsync {
4322 pub fn is_async(self) -> bool {
4323 #[allow(non_exhaustive_omitted_patterns)] match self {
IsAsync::Async(_) => true,
_ => false,
}matches!(self, IsAsync::Async(_))
4324 }
4325}
4326
4327#[derive(#[automatically_derived]
impl ::core::marker::Copy for Defaultness { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Defaultness {
#[inline]
fn clone(&self) -> Defaultness {
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Defaultness {
#[inline]
fn eq(&self, other: &Defaultness) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(Defaultness::Default { has_value: __self_0 },
Defaultness::Default { has_value: __arg1_0 }) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Defaultness {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for Defaultness {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Defaultness::Default { has_value: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Default", "has_value", &__self_0),
Defaultness::Final =>
::core::fmt::Formatter::write_str(f, "Final"),
}
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Defaultness {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Defaultness::Default { has_value: ref __binding_0 } => {
0usize
}
Defaultness::Final => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Defaultness::Default { has_value: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
Defaultness::Final => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Defaultness {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
Defaultness::Default {
has_value: ::rustc_serialize::Decodable::decode(__decoder),
}
}
1usize => { Defaultness::Final }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Defaultness`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Defaultness
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
Defaultness::Default { has_value: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Defaultness::Final => {}
}
}
}
};StableHash)]
4328#[derive(#[automatically_derived]
impl ::core::default::Default for Defaultness {
#[inline]
fn default() -> Defaultness { Self::Final }
}Default)]
4329pub enum Defaultness {
4330 Default {
4331 has_value: bool,
4332 },
4333 #[default]
4334 Final,
4335}
4336
4337impl Defaultness {
4338 pub fn has_value(&self) -> bool {
4339 match *self {
4340 Defaultness::Default { has_value } => has_value,
4341 Defaultness::Final => true,
4342 }
4343 }
4344
4345 pub fn is_final(&self) -> bool {
4346 *self == Defaultness::Final
4347 }
4348
4349 pub fn is_default(&self) -> bool {
4350 #[allow(non_exhaustive_omitted_patterns)] match *self {
Defaultness::Default { .. } => true,
_ => false,
}matches!(*self, Defaultness::Default { .. })
4351 }
4352}
4353
4354#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnRetTy<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
FnRetTy::DefaultReturn(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"DefaultReturn", &__self_0),
FnRetTy::Return(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Return",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnRetTy<'hir> {
#[inline]
fn clone(&self) -> FnRetTy<'hir> {
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnRetTy<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
FnRetTy<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
FnRetTy::DefaultReturn(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
FnRetTy::Return(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4355pub enum FnRetTy<'hir> {
4356 DefaultReturn(Span),
4362 Return(&'hir Ty<'hir>),
4364}
4365
4366impl<'hir> FnRetTy<'hir> {
4367 #[inline]
4368 pub fn span(&self) -> Span {
4369 match *self {
4370 Self::DefaultReturn(span) => span,
4371 Self::Return(ref ty) => ty.span,
4372 }
4373 }
4374
4375 pub fn is_suggestable_infer_ty(&self) -> Option<&'hir Ty<'hir>> {
4376 if let Self::Return(ty) = self
4377 && ty.is_suggestable_infer_ty()
4378 {
4379 return Some(*ty);
4380 }
4381 None
4382 }
4383}
4384
4385#[derive(#[automatically_derived]
impl ::core::marker::Copy for ClosureBinder { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ClosureBinder {
#[inline]
fn clone(&self) -> ClosureBinder {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ClosureBinder {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ClosureBinder::Default =>
::core::fmt::Formatter::write_str(f, "Default"),
ClosureBinder::For { span: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "For",
"span", &__self_0),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
ClosureBinder {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ClosureBinder::Default => {}
ClosureBinder::For { span: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4387pub enum ClosureBinder {
4388 Default,
4390 For { span: Span },
4394}
4395
4396#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Mod<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Mod", "spans",
&self.spans, "item_ids", &&self.item_ids)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Mod<'hir> {
#[inline]
fn clone(&self) -> Mod<'hir> {
let _: ::core::clone::AssertParamIsClone<ModSpans>;
let _: ::core::clone::AssertParamIsClone<&'hir [ItemId]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Mod<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Mod<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Mod { spans: ref __binding_0, item_ids: ref __binding_1 } =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4397pub struct Mod<'hir> {
4398 pub spans: ModSpans,
4399 pub item_ids: &'hir [ItemId],
4400}
4401
4402#[derive(#[automatically_derived]
impl ::core::marker::Copy for ModSpans { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ModSpans {
#[inline]
fn clone(&self) -> ModSpans {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ModSpans {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "ModSpans",
"inner_span", &self.inner_span, "inject_use_span",
&&self.inject_use_span)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for ModSpans {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ModSpans {
inner_span: ref __binding_0,
inject_use_span: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4403pub struct ModSpans {
4404 pub inner_span: Span,
4408 pub inject_use_span: Span,
4409}
4410
4411#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for EnumDef<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "EnumDef",
"variants", &&self.variants)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for EnumDef<'hir> {
#[inline]
fn clone(&self) -> EnumDef<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [Variant<'hir>]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for EnumDef<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
EnumDef<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
EnumDef { variants: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4412pub struct EnumDef<'hir> {
4413 pub variants: &'hir [Variant<'hir>],
4414}
4415
4416#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Variant<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["ident", "hir_id", "def_id", "data", "disr_expr", "span"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.hir_id, &self.def_id, &self.data,
&self.disr_expr, &&self.span];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Variant",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Variant<'hir> {
#[inline]
fn clone(&self) -> Variant<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<VariantData<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir AnonConst>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Variant<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Variant<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Variant {
ident: ref __binding_0,
hir_id: ref __binding_1,
def_id: ref __binding_2,
data: ref __binding_3,
disr_expr: ref __binding_4,
span: ref __binding_5 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{}
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4417pub struct Variant<'hir> {
4418 pub ident: Ident,
4420 #[stable_hash(ignore)]
4422 pub hir_id: HirId,
4423 pub def_id: LocalDefId,
4424 pub data: VariantData<'hir>,
4426 pub disr_expr: Option<&'hir AnonConst>,
4428 pub span: Span,
4430}
4431
4432#[derive(#[automatically_derived]
impl ::core::marker::Copy for UseKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for UseKind {
#[inline]
fn clone(&self) -> UseKind {
let _: ::core::clone::AssertParamIsClone<Ident>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for UseKind {
#[inline]
fn eq(&self, other: &UseKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(UseKind::Single(__self_0), UseKind::Single(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for UseKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
UseKind::Single(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Single",
&__self_0),
UseKind::Glob => ::core::fmt::Formatter::write_str(f, "Glob"),
UseKind::ListStem =>
::core::fmt::Formatter::write_str(f, "ListStem"),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for UseKind {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
UseKind::Single(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
UseKind::Glob => {}
UseKind::ListStem => {}
}
}
}
};StableHash)]
4433pub enum UseKind {
4434 Single(Ident),
4441
4442 Glob,
4444
4445 ListStem,
4449}
4450
4451#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitRef<'hir> {
#[inline]
fn clone(&self) -> TraitRef<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Path<'hir>>;
let _: ::core::clone::AssertParamIsClone<HirId>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitRef<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "TraitRef",
"path", &self.path, "hir_ref_id", &&self.hir_ref_id)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitRef<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
TraitRef<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TraitRef {
path: ref __binding_0, hir_ref_id: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{}
}
}
}
}
};StableHash)]
4458pub struct TraitRef<'hir> {
4459 pub path: &'hir Path<'hir>,
4460 #[stable_hash(ignore)]
4462 pub hir_ref_id: HirId,
4463}
4464
4465impl TraitRef<'_> {
4466 pub fn trait_def_id(&self) -> Option<DefId> {
4468 match self.path.res {
4469 Res::Def(DefKind::Trait | DefKind::TraitAlias, did) => Some(did),
4470 Res::Err => None,
4471 res => {
::core::panicking::panic_fmt(format_args!("{0:?} did not resolve to a trait or trait alias",
res));
}panic!("{res:?} did not resolve to a trait or trait alias"),
4472 }
4473 }
4474}
4475
4476#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for PolyTraitRef<'hir> {
#[inline]
fn clone(&self) -> PolyTraitRef<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _: ::core::clone::AssertParamIsClone<TraitBoundModifiers>;
let _: ::core::clone::AssertParamIsClone<TraitRef<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for PolyTraitRef<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "PolyTraitRef",
"bound_generic_params", &self.bound_generic_params, "modifiers",
&self.modifiers, "trait_ref", &self.trait_ref, "span",
&&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PolyTraitRef<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
PolyTraitRef<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
PolyTraitRef {
bound_generic_params: ref __binding_0,
modifiers: ref __binding_1,
trait_ref: ref __binding_2,
span: ref __binding_3 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4477pub struct PolyTraitRef<'hir> {
4478 pub bound_generic_params: &'hir [GenericParam<'hir>],
4480
4481 pub modifiers: TraitBoundModifiers,
4485
4486 pub trait_ref: TraitRef<'hir>,
4488
4489 pub span: Span,
4490}
4491
4492#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FieldDef<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["span", "vis_span", "ident", "hir_id", "def_id", "ty", "safety",
"default"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.span, &self.vis_span, &self.ident, &self.hir_id,
&self.def_id, &self.ty, &self.safety, &&self.default];
::core::fmt::Formatter::debug_struct_fields_finish(f, "FieldDef",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FieldDef<'hir> {
#[inline]
fn clone(&self) -> FieldDef<'hir> {
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<Safety>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir AnonConst>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FieldDef<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
FieldDef<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
FieldDef {
span: ref __binding_0,
vis_span: ref __binding_1,
ident: ref __binding_2,
hir_id: ref __binding_3,
def_id: ref __binding_4,
ty: ref __binding_5,
safety: ref __binding_6,
default: ref __binding_7 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{}
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
{ __binding_6.stable_hash(__hcx, __hasher); }
{ __binding_7.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4493pub struct FieldDef<'hir> {
4494 pub span: Span,
4495 pub vis_span: Span,
4496 pub ident: Ident,
4497 #[stable_hash(ignore)]
4498 pub hir_id: HirId,
4499 pub def_id: LocalDefId,
4500 pub ty: &'hir Ty<'hir>,
4501 pub safety: Safety,
4502 pub default: Option<&'hir AnonConst>,
4503}
4504
4505impl FieldDef<'_> {
4506 pub fn is_positional(&self) -> bool {
4508 self.ident.as_str().as_bytes()[0].is_ascii_digit()
4509 }
4510}
4511
4512#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for VariantData<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
VariantData::Struct { fields: __self_0, recovered: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"Struct", "fields", __self_0, "recovered", &__self_1),
VariantData::Tuple(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Tuple",
__self_0, __self_1, &__self_2),
VariantData::Unit(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Unit",
__self_0, &__self_1),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for VariantData<'hir> {
#[inline]
fn clone(&self) -> VariantData<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [FieldDef<'hir>]>;
let _: ::core::clone::AssertParamIsClone<ast::Recovered>;
let _: ::core::clone::AssertParamIsClone<&'hir [FieldDef<'hir>]>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for VariantData<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
VariantData<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
VariantData::Struct {
fields: ref __binding_0, recovered: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
VariantData::Tuple(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{}
{ __binding_2.stable_hash(__hcx, __hasher); }
}
VariantData::Unit(ref __binding_0, ref __binding_1) => {
{}
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4514pub enum VariantData<'hir> {
4515 Struct { fields: &'hir [FieldDef<'hir>], recovered: ast::Recovered },
4519 Tuple(&'hir [FieldDef<'hir>], #[stable_hash(ignore)] HirId, LocalDefId),
4523 Unit(#[stable_hash(ignore)] HirId, LocalDefId),
4527}
4528
4529impl<'hir> VariantData<'hir> {
4530 pub fn fields(&self) -> &'hir [FieldDef<'hir>] {
4532 match *self {
4533 VariantData::Struct { fields, .. } | VariantData::Tuple(fields, ..) => fields,
4534 _ => &[],
4535 }
4536 }
4537
4538 pub fn ctor(&self) -> Option<(CtorKind, HirId, LocalDefId)> {
4539 match *self {
4540 VariantData::Tuple(_, hir_id, def_id) => Some((CtorKind::Fn, hir_id, def_id)),
4541 VariantData::Unit(hir_id, def_id) => Some((CtorKind::Const, hir_id, def_id)),
4542 VariantData::Struct { .. } => None,
4543 }
4544 }
4545
4546 #[inline]
4547 pub fn ctor_kind(&self) -> Option<CtorKind> {
4548 self.ctor().map(|(kind, ..)| kind)
4549 }
4550
4551 #[inline]
4553 pub fn ctor_hir_id(&self) -> Option<HirId> {
4554 self.ctor().map(|(_, hir_id, _)| hir_id)
4555 }
4556
4557 #[inline]
4559 pub fn ctor_def_id(&self) -> Option<LocalDefId> {
4560 self.ctor().map(|(.., def_id)| def_id)
4561 }
4562}
4563
4564#[derive(#[automatically_derived]
impl ::core::marker::Copy for ItemId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ItemId {
#[inline]
fn clone(&self) -> ItemId {
let _: ::core::clone::AssertParamIsClone<OwnerId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ItemId {
#[inline]
fn eq(&self, other: &ItemId) -> bool { self.owner_id == other.owner_id }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ItemId {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<OwnerId>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ItemId {
fn encode(&self, __encoder: &mut __E) {
match *self {
ItemId { owner_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ItemId {
fn decode(__decoder: &mut __D) -> Self {
ItemId {
owner_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ItemId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "ItemId",
"owner_id", &&self.owner_id)
}
}Debug, #[automatically_derived]
impl ::core::hash::Hash for ItemId {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.owner_id, state)
}
}Hash, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for ItemId {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ItemId { owner_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4568pub struct ItemId {
4569 pub owner_id: OwnerId,
4570}
4571
4572impl ItemId {
4573 #[inline]
4574 pub fn hir_id(&self) -> HirId {
4575 HirId::make_owner(self.owner_id.def_id)
4577 }
4578}
4579
4580#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Item<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Item",
"owner_id", &self.owner_id, "kind", &self.kind, "span",
&self.span, "vis_span", &self.vis_span, "eii", &&self.eii)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Item<'hir> {
#[inline]
fn clone(&self) -> Item<'hir> {
let _: ::core::clone::AssertParamIsClone<OwnerId>;
let _: ::core::clone::AssertParamIsClone<ItemKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Item<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Item<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Item {
owner_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2,
vis_span: ref __binding_3,
eii: ref __binding_4 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4589pub struct Item<'hir> {
4590 pub owner_id: OwnerId,
4591 pub kind: ItemKind<'hir>,
4592 pub span: Span,
4593 pub vis_span: Span,
4594 pub eii: bool,
4597}
4598
4599impl<'hir> Item<'hir> {
4600 #[inline]
4601 pub fn hir_id(&self) -> HirId {
4602 HirId::make_owner(self.owner_id.def_id)
4604 }
4605
4606 #[inline]
4607 pub fn item_id(&self) -> ItemId {
4608 ItemId { owner_id: self.owner_id }
4609 }
4610
4611 pub fn is_adt(&self) -> bool {
4614 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) => true,
_ => false,
}matches!(self.kind, ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..))
4615 }
4616
4617 pub fn is_struct_or_union(&self) -> bool {
4619 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ItemKind::Struct(..) | ItemKind::Union(..) => true,
_ => false,
}matches!(self.kind, ItemKind::Struct(..) | ItemKind::Union(..))
4620 }
4621
4622 #[track_caller]
pub fn expect_impl(&self) -> &Impl<'hir> {
let ItemKind::Impl(imp) =
&self.kind else { expect_failed("expect_impl", self) };
imp
}expect_methods_self_kind! {
4623 expect_extern_crate, (Option<Symbol>, Ident),
4624 ItemKind::ExternCrate(s, ident), (*s, *ident);
4625
4626 expect_use, (&'hir UsePath<'hir>, UseKind), ItemKind::Use(p, uk), (p, *uk);
4627
4628 expect_static, (Mutability, Ident, &'hir Ty<'hir>, BodyId),
4629 ItemKind::Static(mutbl, ident, ty, body), (*mutbl, *ident, ty, *body);
4630
4631 expect_const, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4632 ItemKind::Const(ident, generics, ty, rhs), (*ident, generics, ty, *rhs);
4633
4634 expect_fn, (Ident, &FnSig<'hir>, &'hir Generics<'hir>, BodyId),
4635 ItemKind::Fn { ident, sig, generics, body, .. }, (*ident, sig, generics, *body);
4636
4637 expect_macro, (Ident, &ast::MacroDef, MacroKinds),
4638 ItemKind::Macro(ident, def, mk), (*ident, def, *mk);
4639
4640 expect_mod, (Ident, &'hir Mod<'hir>), ItemKind::Mod(ident, m), (*ident, m);
4641
4642 expect_foreign_mod, (ExternAbi, &'hir [ForeignItemId]),
4643 ItemKind::ForeignMod { abi, items }, (*abi, items);
4644
4645 expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm { asm, .. }, asm;
4646
4647 expect_ty_alias, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4648 ItemKind::TyAlias(ident, generics, ty), (*ident, generics, ty);
4649
4650 expect_enum, (Ident, &'hir Generics<'hir>, &EnumDef<'hir>),
4651 ItemKind::Enum(ident, generics, def), (*ident, generics, def);
4652
4653 expect_struct, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4654 ItemKind::Struct(ident, generics, data), (*ident, generics, data);
4655
4656 expect_union, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4657 ItemKind::Union(ident, generics, data), (*ident, generics, data);
4658
4659 expect_trait,
4660 (
4661 &'hir ImplRestriction<'hir>,
4662 Constness,
4663 IsAuto,
4664 Safety,
4665 Ident,
4666 &'hir Generics<'hir>,
4667 GenericBounds<'hir>,
4668 &'hir [TraitItemId]
4669 ),
4670 ItemKind::Trait { impl_restriction, constness, is_auto, safety, ident, generics, bounds, items },
4671 (impl_restriction, *constness, *is_auto, *safety, *ident, generics, bounds, items);
4672
4673 expect_trait_alias, (Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4674 ItemKind::TraitAlias(constness, ident, generics, bounds), (*constness, *ident, generics, bounds);
4675
4676 expect_impl, &Impl<'hir>, ItemKind::Impl(imp), imp;
4677 }
4678}
4679
4680#[derive(#[automatically_derived]
impl ::core::marker::Copy for Safety { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Safety {
#[inline]
fn clone(&self) -> Safety { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Safety {
#[inline]
fn eq(&self, other: &Safety) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Safety {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for Safety {
#[inline]
fn partial_cmp(&self, other: &Safety)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for Safety {
#[inline]
fn cmp(&self, other: &Safety) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for Safety {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for Safety {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
Safety::Unsafe => "Unsafe",
Safety::Safe => "Safe",
})
}
}Debug)]
4681#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Safety {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Safety::Unsafe => { 0usize }
Safety::Safe => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self { Safety::Unsafe => {} Safety::Safe => {} }
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Safety {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { Safety::Unsafe }
1usize => { Safety::Safe }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Safety`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Safety {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self { Safety::Unsafe => {} Safety::Safe => {} }
}
}
};StableHash, #[automatically_derived]
impl ::core::default::Default for Safety {
#[inline]
fn default() -> Safety { Self::Unsafe }
}Default)]
4682pub enum Safety {
4683 #[default]
4688 Unsafe,
4689 Safe,
4690}
4691
4692impl Safety {
4693 pub fn prefix_str(self) -> &'static str {
4694 match self {
4695 Self::Unsafe => "unsafe ",
4696 Self::Safe => "",
4697 }
4698 }
4699
4700 #[inline]
4701 pub fn is_unsafe(self) -> bool {
4702 !self.is_safe()
4703 }
4704
4705 #[inline]
4706 pub fn is_safe(self) -> bool {
4707 match self {
4708 Self::Unsafe => false,
4709 Self::Safe => true,
4710 }
4711 }
4712}
4713
4714impl fmt::Display for Safety {
4715 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4716 f.write_str(match *self {
4717 Self::Unsafe => "unsafe",
4718 Self::Safe => "safe",
4719 })
4720 }
4721}
4722
4723#[derive(#[automatically_derived]
impl ::core::marker::Copy for Constness { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Constness {
#[inline]
fn clone(&self) -> Constness {
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Constness {
#[inline]
fn eq(&self, other: &Constness) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(Constness::Const { always: __self_0 }, Constness::Const {
always: __arg1_0 }) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Constness {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for Constness {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Constness::Const { always: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Const",
"always", &__self_0),
Constness::NotConst =>
::core::fmt::Formatter::write_str(f, "NotConst"),
}
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Constness {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Constness::Const { always: ref __binding_0 } => { 0usize }
Constness::NotConst => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Constness::Const { always: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
Constness::NotConst => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Constness {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
Constness::Const {
always: ::rustc_serialize::Decodable::decode(__decoder),
}
}
1usize => { Constness::NotConst }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Constness`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Constness {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
Constness::Const { always: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Constness::NotConst => {}
}
}
}
};StableHash)]
4724pub enum Constness {
4725 Const { always: bool },
4726 NotConst,
4727}
4728
4729impl Default for Constness {
4732 fn default() -> Self {
4733 Self::Const { always: false }
4734 }
4735}
4736
4737impl fmt::Display for Constness {
4738 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4739 f.write_str(match *self {
4740 Self::Const { always: true } => "comptime",
4741 Self::Const { always: false } => "const",
4742 Self::NotConst => "non-const",
4743 })
4744 }
4745}
4746
4747#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ImplRestriction<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"ImplRestriction", "kind", &self.kind, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ImplRestriction<'hir> {
#[inline]
fn clone(&self) -> ImplRestriction<'hir> {
let _: ::core::clone::AssertParamIsClone<RestrictionKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ImplRestriction<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ImplRestriction<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ImplRestriction {
kind: ref __binding_0, span: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4748pub struct ImplRestriction<'hir> {
4749 pub kind: RestrictionKind<'hir>,
4750 pub span: Span,
4751}
4752
4753#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for RestrictionKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
RestrictionKind::Unrestricted =>
::core::fmt::Formatter::write_str(f, "Unrestricted"),
RestrictionKind::Restricted(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Restricted", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for RestrictionKind<'hir> {
#[inline]
fn clone(&self) -> RestrictionKind<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Path<'hir, DefId>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for RestrictionKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
RestrictionKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
RestrictionKind::Unrestricted => {}
RestrictionKind::Restricted(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4754pub enum RestrictionKind<'hir> {
4755 Unrestricted,
4757 Restricted(&'hir Path<'hir, DefId>),
4759}
4760
4761#[derive(#[automatically_derived]
impl ::core::marker::Copy for HeaderSafety { }Copy, #[automatically_derived]
impl ::core::clone::Clone for HeaderSafety {
#[inline]
fn clone(&self) -> HeaderSafety {
let _: ::core::clone::AssertParamIsClone<Safety>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for HeaderSafety {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
HeaderSafety::SafeTargetFeatures =>
::core::fmt::Formatter::write_str(f, "SafeTargetFeatures"),
HeaderSafety::Normal(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Normal",
&__self_0),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for HeaderSafety
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
HeaderSafety::SafeTargetFeatures => {}
HeaderSafety::Normal(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, #[automatically_derived]
impl ::core::cmp::PartialEq for HeaderSafety {
#[inline]
fn eq(&self, other: &HeaderSafety) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(HeaderSafety::Normal(__self_0),
HeaderSafety::Normal(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for HeaderSafety {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Safety>;
}
}Eq)]
4766pub enum HeaderSafety {
4767 SafeTargetFeatures,
4773 Normal(Safety),
4774}
4775
4776impl From<Safety> for HeaderSafety {
4777 fn from(v: Safety) -> Self {
4778 Self::Normal(v)
4779 }
4780}
4781
4782#[derive(#[automatically_derived]
impl ::core::marker::Copy for FnHeader { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FnHeader {
#[inline]
fn clone(&self) -> FnHeader {
let _: ::core::clone::AssertParamIsClone<HeaderSafety>;
let _: ::core::clone::AssertParamIsClone<Constness>;
let _: ::core::clone::AssertParamIsClone<IsAsync>;
let _: ::core::clone::AssertParamIsClone<ExternAbi>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for FnHeader {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "FnHeader",
"safety", &self.safety, "constness", &self.constness, "asyncness",
&self.asyncness, "abi", &&self.abi)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for FnHeader {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
FnHeader {
safety: ref __binding_0,
constness: ref __binding_1,
asyncness: ref __binding_2,
abi: ref __binding_3 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4783pub struct FnHeader {
4784 pub safety: HeaderSafety,
4785 pub constness: Constness,
4786 pub asyncness: IsAsync,
4787 pub abi: ExternAbi,
4788}
4789
4790impl FnHeader {
4791 pub fn is_async(&self) -> bool {
4792 #[allow(non_exhaustive_omitted_patterns)] match self.asyncness {
IsAsync::Async(_) => true,
_ => false,
}matches!(self.asyncness, IsAsync::Async(_))
4793 }
4794
4795 pub fn is_unsafe(&self) -> bool {
4796 self.safety().is_unsafe()
4797 }
4798
4799 pub fn is_safe(&self) -> bool {
4800 self.safety().is_safe()
4801 }
4802
4803 pub fn safety(&self) -> Safety {
4804 match self.safety {
4805 HeaderSafety::SafeTargetFeatures => Safety::Unsafe,
4806 HeaderSafety::Normal(safety) => safety,
4807 }
4808 }
4809}
4810
4811#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ItemKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ItemKind::ExternCrate(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"ExternCrate", __self_0, &__self_1),
ItemKind::Use(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Use",
__self_0, &__self_1),
ItemKind::Static(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f, "Static",
__self_0, __self_1, __self_2, &__self_3),
ItemKind::Const(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f, "Const",
__self_0, __self_1, __self_2, &__self_3),
ItemKind::Fn {
sig: __self_0,
ident: __self_1,
generics: __self_2,
body: __self_3,
has_body: __self_4 } =>
::core::fmt::Formatter::debug_struct_field5_finish(f, "Fn",
"sig", __self_0, "ident", __self_1, "generics", __self_2,
"body", __self_3, "has_body", &__self_4),
ItemKind::Macro(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Macro",
__self_0, __self_1, &__self_2),
ItemKind::Mod(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Mod",
__self_0, &__self_1),
ItemKind::ForeignMod { abi: __self_0, items: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"ForeignMod", "abi", __self_0, "items", &__self_1),
ItemKind::GlobalAsm { asm: __self_0, fake_body: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"GlobalAsm", "asm", __self_0, "fake_body", &__self_1),
ItemKind::TyAlias(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f,
"TyAlias", __self_0, __self_1, &__self_2),
ItemKind::Enum(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Enum",
__self_0, __self_1, &__self_2),
ItemKind::Struct(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Struct",
__self_0, __self_1, &__self_2),
ItemKind::Union(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Union",
__self_0, __self_1, &__self_2),
ItemKind::Trait {
impl_restriction: __self_0,
constness: __self_1,
is_auto: __self_2,
safety: __self_3,
ident: __self_4,
generics: __self_5,
bounds: __self_6,
items: __self_7 } => {
let names: &'static _ =
&["impl_restriction", "constness", "is_auto", "safety",
"ident", "generics", "bounds", "items"];
let values: &[&dyn ::core::fmt::Debug] =
&[__self_0, __self_1, __self_2, __self_3, __self_4,
__self_5, __self_6, &__self_7];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Trait",
names, values)
}
ItemKind::TraitAlias(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f,
"TraitAlias", __self_0, __self_1, __self_2, &__self_3),
ItemKind::Impl(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Impl",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ItemKind<'hir> {
#[inline]
fn clone(&self) -> ItemKind<'hir> {
let _: ::core::clone::AssertParamIsClone<Option<Symbol>>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir UsePath<'hir>>;
let _: ::core::clone::AssertParamIsClone<UseKind>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<ConstItemRhs<'hir>>;
let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<&'hir ast::MacroDef>;
let _: ::core::clone::AssertParamIsClone<MacroKinds>;
let _: ::core::clone::AssertParamIsClone<&'hir Mod<'hir>>;
let _: ::core::clone::AssertParamIsClone<ExternAbi>;
let _: ::core::clone::AssertParamIsClone<&'hir [ForeignItemId]>;
let _: ::core::clone::AssertParamIsClone<&'hir InlineAsm<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<EnumDef<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<VariantData<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<VariantData<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ImplRestriction<'hir>>;
let _: ::core::clone::AssertParamIsClone<Constness>;
let _: ::core::clone::AssertParamIsClone<IsAuto>;
let _: ::core::clone::AssertParamIsClone<Safety>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [TraitItemId]>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
let _: ::core::clone::AssertParamIsClone<Impl<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ItemKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ItemKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ItemKind::ExternCrate(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ItemKind::Use(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ItemKind::Static(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
ItemKind::Const(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
ItemKind::Fn {
sig: ref __binding_0,
ident: ref __binding_1,
generics: ref __binding_2,
body: ref __binding_3,
has_body: ref __binding_4 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
ItemKind::Macro(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ItemKind::Mod(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ItemKind::ForeignMod {
abi: ref __binding_0, items: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ItemKind::GlobalAsm {
asm: ref __binding_0, fake_body: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
ItemKind::TyAlias(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ItemKind::Enum(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ItemKind::Struct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ItemKind::Union(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ItemKind::Trait {
impl_restriction: ref __binding_0,
constness: ref __binding_1,
is_auto: ref __binding_2,
safety: ref __binding_3,
ident: ref __binding_4,
generics: ref __binding_5,
bounds: ref __binding_6,
items: ref __binding_7 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
{ __binding_6.stable_hash(__hcx, __hasher); }
{ __binding_7.stable_hash(__hcx, __hasher); }
}
ItemKind::TraitAlias(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
ItemKind::Impl(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4812pub enum ItemKind<'hir> {
4813 ExternCrate(Option<Symbol>, Ident),
4817
4818 Use(&'hir UsePath<'hir>, UseKind),
4824
4825 Static(Mutability, Ident, &'hir Ty<'hir>, BodyId),
4827 Const(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4829 Fn {
4831 sig: FnSig<'hir>,
4832 ident: Ident,
4833 generics: &'hir Generics<'hir>,
4834 body: BodyId,
4835 has_body: bool,
4839 },
4840 Macro(Ident, &'hir ast::MacroDef, MacroKinds),
4842 Mod(Ident, &'hir Mod<'hir>),
4844 ForeignMod { abi: ExternAbi, items: &'hir [ForeignItemId] },
4846 GlobalAsm {
4848 asm: &'hir InlineAsm<'hir>,
4849 fake_body: BodyId,
4855 },
4856 TyAlias(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4858 Enum(Ident, &'hir Generics<'hir>, EnumDef<'hir>),
4860 Struct(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4862 Union(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4864 Trait {
4866 impl_restriction: &'hir ImplRestriction<'hir>,
4867 constness: Constness,
4868 is_auto: IsAuto,
4869 safety: Safety,
4870 ident: Ident,
4871 generics: &'hir Generics<'hir>,
4872 bounds: GenericBounds<'hir>,
4873 items: &'hir [TraitItemId],
4874 },
4875 TraitAlias(Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4877
4878 Impl(Impl<'hir>),
4880}
4881
4882#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Impl<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Impl",
"generics", &self.generics, "of_trait", &self.of_trait, "self_ty",
&self.self_ty, "items", &self.items, "constness",
&&self.constness)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Impl<'hir> {
#[inline]
fn clone(&self) -> Impl<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _:
::core::clone::AssertParamIsClone<Option<&'hir TraitImplHeader<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [ImplItemId]>;
let _: ::core::clone::AssertParamIsClone<Constness>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Impl<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Impl<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Impl {
generics: ref __binding_0,
of_trait: ref __binding_1,
self_ty: ref __binding_2,
items: ref __binding_3,
constness: ref __binding_4 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4887pub struct Impl<'hir> {
4888 pub generics: &'hir Generics<'hir>,
4889 pub of_trait: Option<&'hir TraitImplHeader<'hir>>,
4890 pub self_ty: &'hir Ty<'hir>,
4891 pub items: &'hir [ImplItemId],
4892 pub constness: Constness,
4893}
4894
4895#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitImplHeader<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f,
"TraitImplHeader", "safety", &self.safety, "polarity",
&self.polarity, "defaultness", &self.defaultness,
"defaultness_span", &self.defaultness_span, "trait_ref",
&&self.trait_ref)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitImplHeader<'hir> {
#[inline]
fn clone(&self) -> TraitImplHeader<'hir> {
let _: ::core::clone::AssertParamIsClone<Safety>;
let _: ::core::clone::AssertParamIsClone<ImplPolarity>;
let _: ::core::clone::AssertParamIsClone<Defaultness>;
let _: ::core::clone::AssertParamIsClone<Option<Span>>;
let _: ::core::clone::AssertParamIsClone<TraitRef<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitImplHeader<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
TraitImplHeader<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TraitImplHeader {
safety: ref __binding_0,
polarity: ref __binding_1,
defaultness: ref __binding_2,
defaultness_span: ref __binding_3,
trait_ref: ref __binding_4 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4896pub struct TraitImplHeader<'hir> {
4897 pub safety: Safety,
4898 pub polarity: ImplPolarity,
4899 pub defaultness: Defaultness,
4900 pub defaultness_span: Option<Span>,
4903 pub trait_ref: TraitRef<'hir>,
4904}
4905
4906impl ItemKind<'_> {
4907 pub fn ident(&self) -> Option<Ident> {
4908 match *self {
4909 ItemKind::ExternCrate(_, ident)
4910 | ItemKind::Use(_, UseKind::Single(ident))
4911 | ItemKind::Static(_, ident, ..)
4912 | ItemKind::Const(ident, ..)
4913 | ItemKind::Fn { ident, .. }
4914 | ItemKind::Macro(ident, ..)
4915 | ItemKind::Mod(ident, ..)
4916 | ItemKind::TyAlias(ident, ..)
4917 | ItemKind::Enum(ident, ..)
4918 | ItemKind::Struct(ident, ..)
4919 | ItemKind::Union(ident, ..)
4920 | ItemKind::Trait { ident, .. }
4921 | ItemKind::TraitAlias(_, ident, ..) => Some(ident),
4922
4923 ItemKind::Use(_, UseKind::Glob | UseKind::ListStem)
4924 | ItemKind::ForeignMod { .. }
4925 | ItemKind::GlobalAsm { .. }
4926 | ItemKind::Impl(_) => None,
4927 }
4928 }
4929
4930 pub fn generics(&self) -> Option<&Generics<'_>> {
4931 Some(match self {
4932 ItemKind::Fn { generics, .. }
4933 | ItemKind::TyAlias(_, generics, _)
4934 | ItemKind::Const(_, generics, _, _)
4935 | ItemKind::Enum(_, generics, _)
4936 | ItemKind::Struct(_, generics, _)
4937 | ItemKind::Union(_, generics, _)
4938 | ItemKind::Trait { generics, .. }
4939 | ItemKind::TraitAlias(_, _, generics, _)
4940 | ItemKind::Impl(Impl { generics, .. }) => generics,
4941 _ => return None,
4942 })
4943 }
4944
4945 pub fn recovered(&self) -> bool {
4946 match self {
4947 ItemKind::Struct(
4948 _,
4949 _,
4950 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4951 ) => true,
4952 ItemKind::Union(
4953 _,
4954 _,
4955 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4956 ) => true,
4957 ItemKind::Enum(_, _, def) => def.variants.iter().any(|v| match v.data {
4958 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. } => true,
4959 _ => false,
4960 }),
4961 _ => false,
4962 }
4963 }
4964}
4965
4966#[derive(#[automatically_derived]
impl ::core::marker::Copy for ForeignItemId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ForeignItemId {
#[inline]
fn clone(&self) -> ForeignItemId {
let _: ::core::clone::AssertParamIsClone<OwnerId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ForeignItemId {
#[inline]
fn eq(&self, other: &ForeignItemId) -> bool {
self.owner_id == other.owner_id
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ForeignItemId {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<OwnerId>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ForeignItemId {
fn encode(&self, __encoder: &mut __E) {
match *self {
ForeignItemId { owner_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ForeignItemId {
fn decode(__decoder: &mut __D) -> Self {
ForeignItemId {
owner_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ForeignItemId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "ForeignItemId",
"owner_id", &&self.owner_id)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
ForeignItemId {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ForeignItemId { owner_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4970pub struct ForeignItemId {
4971 pub owner_id: OwnerId,
4972}
4973
4974impl ForeignItemId {
4975 #[inline]
4976 pub fn hir_id(&self) -> HirId {
4977 HirId::make_owner(self.owner_id.def_id)
4979 }
4980}
4981
4982#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ForeignItem<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "ForeignItem",
"ident", &self.ident, "kind", &self.kind, "owner_id",
&self.owner_id, "span", &self.span, "vis_span", &&self.vis_span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ForeignItem<'hir> {
#[inline]
fn clone(&self) -> ForeignItem<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<ForeignItemKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<OwnerId>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ForeignItem<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ForeignItem<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
ForeignItem {
ident: ref __binding_0,
kind: ref __binding_1,
owner_id: ref __binding_2,
span: ref __binding_3,
vis_span: ref __binding_4 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
4983pub struct ForeignItem<'hir> {
4984 pub ident: Ident,
4985 pub kind: ForeignItemKind<'hir>,
4986 pub owner_id: OwnerId,
4987 pub span: Span,
4988 pub vis_span: Span,
4989}
4990
4991impl ForeignItem<'_> {
4992 #[inline]
4993 pub fn hir_id(&self) -> HirId {
4994 HirId::make_owner(self.owner_id.def_id)
4996 }
4997
4998 pub fn foreign_item_id(&self) -> ForeignItemId {
4999 ForeignItemId { owner_id: self.owner_id }
5000 }
5001}
5002
5003#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ForeignItemKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ForeignItemKind::Fn(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Fn",
__self_0, __self_1, &__self_2),
ForeignItemKind::Static(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Static",
__self_0, __self_1, &__self_2),
ForeignItemKind::Type =>
::core::fmt::Formatter::write_str(f, "Type"),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ForeignItemKind<'hir> {
#[inline]
fn clone(&self) -> ForeignItemKind<'hir> {
let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Option<Ident>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
let _: ::core::clone::AssertParamIsClone<Safety>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ForeignItemKind<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
ForeignItemKind<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ForeignItemKind::Fn(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ForeignItemKind::Static(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
ForeignItemKind::Type => {}
}
}
}
};StableHash)]
5005pub enum ForeignItemKind<'hir> {
5006 Fn(FnSig<'hir>, &'hir [Option<Ident>], &'hir Generics<'hir>),
5013 Static(&'hir Ty<'hir>, Mutability, Safety),
5015 Type,
5017}
5018
5019#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Upvar {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "Upvar", "span",
&&self.span)
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Upvar { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Upvar {
#[inline]
fn clone(&self) -> Upvar {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Upvar {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Upvar { span: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
5021pub struct Upvar {
5022 pub span: Span,
5024}
5025
5026#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitCandidate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"TraitCandidate", "def_id", &self.def_id, "import_ids",
&self.import_ids, "lint_ambiguous", &&self.lint_ambiguous)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitCandidate<'hir> {
#[inline]
fn clone(&self) -> TraitCandidate<'hir> {
let _: ::core::clone::AssertParamIsClone<DefId>;
let _: ::core::clone::AssertParamIsClone<&'hir [LocalDefId]>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitCandidate<'hir> { }Copy, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
TraitCandidate<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TraitCandidate {
def_id: ref __binding_0,
import_ids: ref __binding_1,
lint_ambiguous: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
5030pub struct TraitCandidate<'hir> {
5031 pub def_id: DefId,
5032 pub import_ids: &'hir [LocalDefId],
5033 pub lint_ambiguous: bool,
5038}
5039
5040#[derive(#[automatically_derived]
impl<'hir> ::core::marker::Copy for OwnerNode<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::clone::Clone for OwnerNode<'hir> {
#[inline]
fn clone(&self) -> OwnerNode<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Item<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ForeignItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir TraitItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ImplItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Mod<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for OwnerNode<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
OwnerNode::Item(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Item",
&__self_0),
OwnerNode::ForeignItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ForeignItem", &__self_0),
OwnerNode::TraitItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TraitItem", &__self_0),
OwnerNode::ImplItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ImplItem", &__self_0),
OwnerNode::Crate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Crate",
&__self_0),
OwnerNode::Synthetic =>
::core::fmt::Formatter::write_str(f, "Synthetic"),
}
}
}Debug, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
OwnerNode<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
OwnerNode::Item(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
OwnerNode::ForeignItem(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
OwnerNode::TraitItem(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
OwnerNode::ImplItem(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
OwnerNode::Crate(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
OwnerNode::Synthetic => {}
}
}
}
};StableHash)]
5041pub enum OwnerNode<'hir> {
5042 Item(&'hir Item<'hir>),
5043 ForeignItem(&'hir ForeignItem<'hir>),
5044 TraitItem(&'hir TraitItem<'hir>),
5045 ImplItem(&'hir ImplItem<'hir>),
5046 Crate(&'hir Mod<'hir>),
5047 Synthetic,
5048}
5049
5050impl<'hir> OwnerNode<'hir> {
5051 pub fn span(&self) -> Span {
5052 match self {
5053 OwnerNode::Item(Item { span, .. })
5054 | OwnerNode::ForeignItem(ForeignItem { span, .. })
5055 | OwnerNode::ImplItem(ImplItem { span, .. })
5056 | OwnerNode::TraitItem(TraitItem { span, .. }) => *span,
5057 OwnerNode::Crate(Mod { spans: ModSpans { inner_span, .. }, .. }) => *inner_span,
5058 OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
5059 }
5060 }
5061
5062 pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
5063 match self {
5064 OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
5065 | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
5066 | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
5067 | OwnerNode::ForeignItem(ForeignItem {
5068 kind: ForeignItemKind::Fn(fn_sig, _, _), ..
5069 }) => Some(fn_sig),
5070 _ => None,
5071 }
5072 }
5073
5074 pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
5075 match self {
5076 OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
5077 | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
5078 | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
5079 | OwnerNode::ForeignItem(ForeignItem {
5080 kind: ForeignItemKind::Fn(fn_sig, _, _), ..
5081 }) => Some(fn_sig.decl),
5082 _ => None,
5083 }
5084 }
5085
5086 pub fn body_id(&self) -> Option<BodyId> {
5087 match self {
5088 OwnerNode::Item(Item {
5089 kind:
5090 ItemKind::Static(_, _, _, body)
5091 | ItemKind::Const(.., ConstItemRhs::Body(body))
5092 | ItemKind::Fn { body, .. },
5093 ..
5094 })
5095 | OwnerNode::TraitItem(TraitItem {
5096 kind:
5097 TraitItemKind::Fn(_, TraitFn::Provided(body))
5098 | TraitItemKind::Const(_, Some(ConstItemRhs::Body(body))),
5099 ..
5100 })
5101 | OwnerNode::ImplItem(ImplItem {
5102 kind: ImplItemKind::Fn(_, body) | ImplItemKind::Const(_, ConstItemRhs::Body(body)),
5103 ..
5104 }) => Some(*body),
5105 _ => None,
5106 }
5107 }
5108
5109 pub fn generics(self) -> Option<&'hir Generics<'hir>> {
5110 Node::generics(self.into())
5111 }
5112
5113 pub fn def_id(self) -> OwnerId {
5114 match self {
5115 OwnerNode::Item(Item { owner_id, .. })
5116 | OwnerNode::TraitItem(TraitItem { owner_id, .. })
5117 | OwnerNode::ImplItem(ImplItem { owner_id, .. })
5118 | OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
5119 OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
5120 OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
5121 }
5122 }
5123
5124 pub fn is_impl_block(&self) -> bool {
5126 #[allow(non_exhaustive_omitted_patterns)] match self {
OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }) => true,
_ => false,
}matches!(self, OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }))
5127 }
5128
5129 #[track_caller]
pub fn expect_trait_item(&self) -> &'hir TraitItem<'hir> {
let OwnerNode::TraitItem(n) =
self else { expect_failed("expect_trait_item", self) };
n
}expect_methods_self! {
5130 expect_item, &'hir Item<'hir>, OwnerNode::Item(n), n;
5131 expect_foreign_item, &'hir ForeignItem<'hir>, OwnerNode::ForeignItem(n), n;
5132 expect_impl_item, &'hir ImplItem<'hir>, OwnerNode::ImplItem(n), n;
5133 expect_trait_item, &'hir TraitItem<'hir>, OwnerNode::TraitItem(n), n;
5134 }
5135}
5136
5137impl<'hir> From<&'hir Item<'hir>> for OwnerNode<'hir> {
5138 fn from(val: &'hir Item<'hir>) -> Self {
5139 OwnerNode::Item(val)
5140 }
5141}
5142
5143impl<'hir> From<&'hir ForeignItem<'hir>> for OwnerNode<'hir> {
5144 fn from(val: &'hir ForeignItem<'hir>) -> Self {
5145 OwnerNode::ForeignItem(val)
5146 }
5147}
5148
5149impl<'hir> From<&'hir ImplItem<'hir>> for OwnerNode<'hir> {
5150 fn from(val: &'hir ImplItem<'hir>) -> Self {
5151 OwnerNode::ImplItem(val)
5152 }
5153}
5154
5155impl<'hir> From<&'hir TraitItem<'hir>> for OwnerNode<'hir> {
5156 fn from(val: &'hir TraitItem<'hir>) -> Self {
5157 OwnerNode::TraitItem(val)
5158 }
5159}
5160
5161impl<'hir> From<OwnerNode<'hir>> for Node<'hir> {
5162 fn from(val: OwnerNode<'hir>) -> Self {
5163 match val {
5164 OwnerNode::Item(n) => Node::Item(n),
5165 OwnerNode::ForeignItem(n) => Node::ForeignItem(n),
5166 OwnerNode::ImplItem(n) => Node::ImplItem(n),
5167 OwnerNode::TraitItem(n) => Node::TraitItem(n),
5168 OwnerNode::Crate(n) => Node::Crate(n),
5169 OwnerNode::Synthetic => Node::Synthetic,
5170 }
5171 }
5172}
5173
5174#[derive(#[automatically_derived]
impl<'hir> ::core::marker::Copy for Node<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Node<'hir> {
#[inline]
fn clone(&self) -> Node<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Param<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Item<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ForeignItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir TraitItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ImplItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Variant<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir FieldDef<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir AnonConst>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstBlock>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ExprField<'hir>>;
let _:
::core::clone::AssertParamIsClone<&'hir ConstArgExprField<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Stmt<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir PathSegment<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _:
::core::clone::AssertParamIsClone<&'hir AssocItemConstraint<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir TraitRef<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir OpaqueTy<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir TyPat<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir PatField<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir PatExpr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Arm<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir LetStmt<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir VariantData<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
let _: ::core::clone::AssertParamIsClone<&'hir GenericParam<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Mod<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir InferArg>;
let _: ::core::clone::AssertParamIsClone<&'hir WherePredicate<'hir>>;
let _:
::core::clone::AssertParamIsClone<&'hir PreciseCapturingNonLifetimeArg>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for Node<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Node::Param(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Param",
&__self_0),
Node::Item(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Item",
&__self_0),
Node::ForeignItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ForeignItem", &__self_0),
Node::TraitItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TraitItem", &__self_0),
Node::ImplItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ImplItem", &__self_0),
Node::Variant(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Variant", &__self_0),
Node::Field(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Field",
&__self_0),
Node::AnonConst(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"AnonConst", &__self_0),
Node::ConstBlock(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ConstBlock", &__self_0),
Node::ConstArg(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ConstArg", &__self_0),
Node::Expr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Expr",
&__self_0),
Node::ExprField(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ExprField", &__self_0),
Node::ConstArgExprField(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ConstArgExprField", &__self_0),
Node::Stmt(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Stmt",
&__self_0),
Node::PathSegment(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"PathSegment", &__self_0),
Node::Ty(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ty",
&__self_0),
Node::AssocItemConstraint(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"AssocItemConstraint", &__self_0),
Node::TraitRef(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TraitRef", &__self_0),
Node::OpaqueTy(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"OpaqueTy", &__self_0),
Node::TyPat(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "TyPat",
&__self_0),
Node::Pat(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Pat",
&__self_0),
Node::PatField(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"PatField", &__self_0),
Node::PatExpr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"PatExpr", &__self_0),
Node::Arm(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Arm",
&__self_0),
Node::Block(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Block",
&__self_0),
Node::LetStmt(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"LetStmt", &__self_0),
Node::Ctor(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ctor",
&__self_0),
Node::Lifetime(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Lifetime", &__self_0),
Node::GenericParam(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"GenericParam", &__self_0),
Node::Crate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Crate",
&__self_0),
Node::Infer(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
&__self_0),
Node::WherePredicate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"WherePredicate", &__self_0),
Node::PreciseCapturingNonLifetimeArg(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"PreciseCapturingNonLifetimeArg", &__self_0),
Node::Synthetic =>
::core::fmt::Formatter::write_str(f, "Synthetic"),
Node::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
}
}
}Debug, const _: () =
{
impl<'hir> ::rustc_data_structures::stable_hash::StableHash for
Node<'hir> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
Node::Param(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Item(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::ForeignItem(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::TraitItem(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::ImplItem(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Variant(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Field(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::AnonConst(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::ConstBlock(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::ConstArg(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Expr(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::ExprField(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::ConstArgExprField(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Stmt(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::PathSegment(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Ty(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::AssocItemConstraint(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::TraitRef(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::OpaqueTy(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::TyPat(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Pat(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::PatField(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::PatExpr(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Arm(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Block(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::LetStmt(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Ctor(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Lifetime(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::GenericParam(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Crate(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Infer(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::WherePredicate(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::PreciseCapturingNonLifetimeArg(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Node::Synthetic => {}
Node::Err(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
5175pub enum Node<'hir> {
5176 Param(&'hir Param<'hir>),
5177 Item(&'hir Item<'hir>),
5178 ForeignItem(&'hir ForeignItem<'hir>),
5179 TraitItem(&'hir TraitItem<'hir>),
5180 ImplItem(&'hir ImplItem<'hir>),
5181 Variant(&'hir Variant<'hir>),
5182 Field(&'hir FieldDef<'hir>),
5183 AnonConst(&'hir AnonConst),
5184 ConstBlock(&'hir ConstBlock),
5185 ConstArg(&'hir ConstArg<'hir>),
5186 Expr(&'hir Expr<'hir>),
5187 ExprField(&'hir ExprField<'hir>),
5188 ConstArgExprField(&'hir ConstArgExprField<'hir>),
5189 Stmt(&'hir Stmt<'hir>),
5190 PathSegment(&'hir PathSegment<'hir>),
5191 Ty(&'hir Ty<'hir>),
5192 AssocItemConstraint(&'hir AssocItemConstraint<'hir>),
5193 TraitRef(&'hir TraitRef<'hir>),
5194 OpaqueTy(&'hir OpaqueTy<'hir>),
5195 TyPat(&'hir TyPat<'hir>),
5196 Pat(&'hir Pat<'hir>),
5197 PatField(&'hir PatField<'hir>),
5198 PatExpr(&'hir PatExpr<'hir>),
5202 Arm(&'hir Arm<'hir>),
5203 Block(&'hir Block<'hir>),
5204 LetStmt(&'hir LetStmt<'hir>),
5205 Ctor(&'hir VariantData<'hir>),
5208 Lifetime(&'hir Lifetime),
5209 GenericParam(&'hir GenericParam<'hir>),
5210 Crate(&'hir Mod<'hir>),
5211 Infer(&'hir InferArg),
5212 WherePredicate(&'hir WherePredicate<'hir>),
5213 PreciseCapturingNonLifetimeArg(&'hir PreciseCapturingNonLifetimeArg),
5214 Synthetic,
5216 Err(Span),
5217}
5218
5219impl<'hir> Node<'hir> {
5220 pub fn ident(&self) -> Option<Ident> {
5235 match self {
5236 Node::Item(item) => item.kind.ident(),
5237 Node::TraitItem(TraitItem { ident, .. })
5238 | Node::ImplItem(ImplItem { ident, .. })
5239 | Node::ForeignItem(ForeignItem { ident, .. })
5240 | Node::Field(FieldDef { ident, .. })
5241 | Node::Variant(Variant { ident, .. })
5242 | Node::PathSegment(PathSegment { ident, .. }) => Some(*ident),
5243 Node::Lifetime(lt) => Some(lt.ident),
5244 Node::GenericParam(p) => Some(p.name.ident()),
5245 Node::AssocItemConstraint(c) => Some(c.ident),
5246 Node::PatField(f) => Some(f.ident),
5247 Node::ExprField(f) => Some(f.ident),
5248 Node::ConstArgExprField(f) => Some(f.field),
5249 Node::PreciseCapturingNonLifetimeArg(a) => Some(a.ident),
5250 Node::Param(..)
5251 | Node::AnonConst(..)
5252 | Node::ConstBlock(..)
5253 | Node::ConstArg(..)
5254 | Node::Expr(..)
5255 | Node::Stmt(..)
5256 | Node::Block(..)
5257 | Node::Ctor(..)
5258 | Node::Pat(..)
5259 | Node::TyPat(..)
5260 | Node::PatExpr(..)
5261 | Node::Arm(..)
5262 | Node::LetStmt(..)
5263 | Node::Crate(..)
5264 | Node::Ty(..)
5265 | Node::TraitRef(..)
5266 | Node::OpaqueTy(..)
5267 | Node::Infer(..)
5268 | Node::WherePredicate(..)
5269 | Node::Synthetic
5270 | Node::Err(..) => None,
5271 }
5272 }
5273
5274 pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
5275 match self {
5276 Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
5277 | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
5278 | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
5279 | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
5280 Some(fn_sig.decl)
5281 }
5282 Node::Expr(Expr { kind: ExprKind::Closure(Closure { fn_decl, .. }), .. }) => {
5283 Some(fn_decl)
5284 }
5285 _ => None,
5286 }
5287 }
5288
5289 pub fn impl_block_of_trait(self, trait_def_id: DefId) -> Option<&'hir Impl<'hir>> {
5291 if let Node::Item(Item { kind: ItemKind::Impl(impl_block), .. }) = self
5292 && let Some(of_trait) = impl_block.of_trait
5293 && let Some(trait_id) = of_trait.trait_ref.trait_def_id()
5294 && trait_id == trait_def_id
5295 {
5296 Some(impl_block)
5297 } else {
5298 None
5299 }
5300 }
5301
5302 pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
5303 match self {
5304 Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
5305 | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
5306 | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
5307 | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
5308 Some(fn_sig)
5309 }
5310 _ => None,
5311 }
5312 }
5313
5314 pub fn ty(self) -> Option<&'hir Ty<'hir>> {
5316 match self {
5317 Node::Item(it) => match it.kind {
5318 ItemKind::TyAlias(_, _, ty)
5319 | ItemKind::Static(_, _, ty, _)
5320 | ItemKind::Const(_, _, ty, _) => Some(ty),
5321 ItemKind::Impl(impl_item) => Some(&impl_item.self_ty),
5322 _ => None,
5323 },
5324 Node::TraitItem(it) => match it.kind {
5325 TraitItemKind::Const(ty, _) => Some(ty),
5326 TraitItemKind::Type(_, ty) => ty,
5327 _ => None,
5328 },
5329 Node::ImplItem(it) => match it.kind {
5330 ImplItemKind::Const(ty, _) => Some(ty),
5331 ImplItemKind::Type(ty) => Some(ty),
5332 _ => None,
5333 },
5334 Node::ForeignItem(it) => match it.kind {
5335 ForeignItemKind::Static(ty, ..) => Some(ty),
5336 _ => None,
5337 },
5338 Node::GenericParam(param) => match param.kind {
5339 GenericParamKind::Lifetime { .. } => None,
5340 GenericParamKind::Type { default, .. } => default,
5341 GenericParamKind::Const { ty, .. } => Some(ty),
5342 },
5343 Node::Field(f) => Some(f.ty),
5344 _ => None,
5345 }
5346 }
5347
5348 pub fn alias_ty(self) -> Option<&'hir Ty<'hir>> {
5349 match self {
5350 Node::Item(Item { kind: ItemKind::TyAlias(_, _, ty), .. }) => Some(ty),
5351 _ => None,
5352 }
5353 }
5354
5355 #[inline]
5356 pub fn associated_body(&self) -> Option<(LocalDefId, BodyId)> {
5357 match self {
5358 Node::Item(Item {
5359 owner_id,
5360 kind:
5361 ItemKind::Const(.., ConstItemRhs::Body(body))
5362 | ItemKind::Static(.., body)
5363 | ItemKind::Fn { body, .. },
5364 ..
5365 })
5366 | Node::TraitItem(TraitItem {
5367 owner_id,
5368 kind:
5369 TraitItemKind::Const(_, Some(ConstItemRhs::Body(body)))
5370 | TraitItemKind::Fn(_, TraitFn::Provided(body)),
5371 ..
5372 })
5373 | Node::ImplItem(ImplItem {
5374 owner_id,
5375 kind: ImplItemKind::Const(.., ConstItemRhs::Body(body)) | ImplItemKind::Fn(_, body),
5376 ..
5377 }) => Some((owner_id.def_id, *body)),
5378
5379 Node::Item(Item {
5380 owner_id, kind: ItemKind::GlobalAsm { asm: _, fake_body }, ..
5381 }) => Some((owner_id.def_id, *fake_body)),
5382
5383 Node::Expr(Expr { kind: ExprKind::Closure(Closure { def_id, body, .. }), .. }) => {
5384 Some((*def_id, *body))
5385 }
5386
5387 Node::AnonConst(constant) => Some((constant.def_id, constant.body)),
5388 Node::ConstBlock(constant) => Some((constant.def_id, constant.body)),
5389
5390 _ => None,
5391 }
5392 }
5393
5394 pub fn body_id(&self) -> Option<BodyId> {
5395 Some(self.associated_body()?.1)
5396 }
5397
5398 pub fn generics(self) -> Option<&'hir Generics<'hir>> {
5399 match self {
5400 Node::ForeignItem(ForeignItem {
5401 kind: ForeignItemKind::Fn(_, _, generics), ..
5402 })
5403 | Node::TraitItem(TraitItem { generics, .. })
5404 | Node::ImplItem(ImplItem { generics, .. }) => Some(generics),
5405 Node::Item(item) => item.kind.generics(),
5406 _ => None,
5407 }
5408 }
5409
5410 pub fn as_owner(self) -> Option<OwnerNode<'hir>> {
5411 match self {
5412 Node::Item(i) => Some(OwnerNode::Item(i)),
5413 Node::ForeignItem(i) => Some(OwnerNode::ForeignItem(i)),
5414 Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
5415 Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
5416 Node::Crate(i) => Some(OwnerNode::Crate(i)),
5417 Node::Synthetic => Some(OwnerNode::Synthetic),
5418 _ => None,
5419 }
5420 }
5421
5422 pub fn fn_kind(self) -> Option<FnKind<'hir>> {
5423 match self {
5424 Node::Item(i) => match i.kind {
5425 ItemKind::Fn { ident, sig, generics, .. } => {
5426 Some(FnKind::ItemFn(ident, generics, sig.header))
5427 }
5428 _ => None,
5429 },
5430 Node::TraitItem(ti) => match ti.kind {
5431 TraitItemKind::Fn(ref sig, _) => Some(FnKind::Method(ti.ident, sig)),
5432 _ => None,
5433 },
5434 Node::ImplItem(ii) => match ii.kind {
5435 ImplItemKind::Fn(ref sig, _) => Some(FnKind::Method(ii.ident, sig)),
5436 _ => None,
5437 },
5438 Node::Expr(e) => match e.kind {
5439 ExprKind::Closure { .. } => Some(FnKind::Closure),
5440 _ => None,
5441 },
5442 _ => None,
5443 }
5444 }
5445
5446 pub fn path(self) -> Option<&'hir QPath<'hir>> {
5448 match self {
5449 Node::Ty(Ty { kind: TyKind::Path(path), .. })
5450 | Node::Expr(Expr { kind: ExprKind::Path(path), .. })
5451 | Node::PatExpr(PatExpr { kind: PatExprKind::Path(path), .. }) => Some(path),
5452 _ => None,
5453 }
5454 }
5455
5456 #[track_caller]
pub fn expect_closure(&self) -> &'hir Closure<'hir> {
let Node::Expr(Expr { kind: ExprKind::Closure(n), .. }) =
self else { expect_failed("expect_closure", self) };
n
}expect_methods_self! {
5457 expect_param, &'hir Param<'hir>, Node::Param(n), n;
5458 expect_item, &'hir Item<'hir>, Node::Item(n), n;
5459 expect_foreign_item, &'hir ForeignItem<'hir>, Node::ForeignItem(n), n;
5460 expect_trait_item, &'hir TraitItem<'hir>, Node::TraitItem(n), n;
5461 expect_impl_item, &'hir ImplItem<'hir>, Node::ImplItem(n), n;
5462 expect_variant, &'hir Variant<'hir>, Node::Variant(n), n;
5463 expect_field, &'hir FieldDef<'hir>, Node::Field(n), n;
5464 expect_anon_const, &'hir AnonConst, Node::AnonConst(n), n;
5465 expect_inline_const, &'hir ConstBlock, Node::ConstBlock(n), n;
5466 expect_expr, &'hir Expr<'hir>, Node::Expr(n), n;
5467 expect_expr_field, &'hir ExprField<'hir>, Node::ExprField(n), n;
5468 expect_stmt, &'hir Stmt<'hir>, Node::Stmt(n), n;
5469 expect_path_segment, &'hir PathSegment<'hir>, Node::PathSegment(n), n;
5470 expect_ty, &'hir Ty<'hir>, Node::Ty(n), n;
5471 expect_assoc_item_constraint, &'hir AssocItemConstraint<'hir>, Node::AssocItemConstraint(n), n;
5472 expect_trait_ref, &'hir TraitRef<'hir>, Node::TraitRef(n), n;
5473 expect_opaque_ty, &'hir OpaqueTy<'hir>, Node::OpaqueTy(n), n;
5474 expect_pat, &'hir Pat<'hir>, Node::Pat(n), n;
5475 expect_pat_field, &'hir PatField<'hir>, Node::PatField(n), n;
5476 expect_arm, &'hir Arm<'hir>, Node::Arm(n), n;
5477 expect_block, &'hir Block<'hir>, Node::Block(n), n;
5478 expect_let_stmt, &'hir LetStmt<'hir>, Node::LetStmt(n), n;
5479 expect_ctor, &'hir VariantData<'hir>, Node::Ctor(n), n;
5480 expect_lifetime, &'hir Lifetime, Node::Lifetime(n), n;
5481 expect_generic_param, &'hir GenericParam<'hir>, Node::GenericParam(n), n;
5482 expect_crate, &'hir Mod<'hir>, Node::Crate(n), n;
5483 expect_infer, &'hir InferArg, Node::Infer(n), n;
5484 expect_closure, &'hir Closure<'hir>, Node::Expr(Expr { kind: ExprKind::Closure(n), .. }), n;
5485 }
5486}
5487
5488#[cfg(target_pointer_width = "64")]
5490mod size_asserts {
5491 use rustc_data_structures::static_assert_size;
5492
5493 use super::*;
5494 const _: [(); 48] = [(); ::std::mem::size_of::<Block<'_>>()];static_assert_size!(Block<'_>, 48);
5496 const _: [(); 24] = [(); ::std::mem::size_of::<Body<'_>>()];static_assert_size!(Body<'_>, 24);
5497 const _: [(); 64] = [(); ::std::mem::size_of::<Expr<'_>>()];static_assert_size!(Expr<'_>, 64);
5498 const _: [(); 48] = [(); ::std::mem::size_of::<ExprKind<'_>>()];static_assert_size!(ExprKind<'_>, 48);
5499 const _: [(); 40] = [(); ::std::mem::size_of::<FnDecl<'_>>()];static_assert_size!(FnDecl<'_>, 40);
5500 const _: [(); 88] = [(); ::std::mem::size_of::<ForeignItem<'_>>()];static_assert_size!(ForeignItem<'_>, 88);
5501 const _: [(); 56] = [(); ::std::mem::size_of::<ForeignItemKind<'_>>()];static_assert_size!(ForeignItemKind<'_>, 56);
5502 const _: [(); 16] = [(); ::std::mem::size_of::<GenericArg<'_>>()];static_assert_size!(GenericArg<'_>, 16);
5503 const _: [(); 64] = [(); ::std::mem::size_of::<GenericBound<'_>>()];static_assert_size!(GenericBound<'_>, 64);
5504 const _: [(); 56] = [(); ::std::mem::size_of::<Generics<'_>>()];static_assert_size!(Generics<'_>, 56);
5505 const _: [(); 48] = [(); ::std::mem::size_of::<Impl<'_>>()];static_assert_size!(Impl<'_>, 48);
5506 const _: [(); 88] = [(); ::std::mem::size_of::<ImplItem<'_>>()];static_assert_size!(ImplItem<'_>, 88);
5507 const _: [(); 40] = [(); ::std::mem::size_of::<ImplItemKind<'_>>()];static_assert_size!(ImplItemKind<'_>, 40);
5508 const _: [(); 88] = [(); ::std::mem::size_of::<Item<'_>>()];static_assert_size!(Item<'_>, 88);
5509 const _: [(); 64] = [(); ::std::mem::size_of::<ItemKind<'_>>()];static_assert_size!(ItemKind<'_>, 64);
5510 const _: [(); 64] = [(); ::std::mem::size_of::<LetStmt<'_>>()];static_assert_size!(LetStmt<'_>, 64);
5511 const _: [(); 32] = [(); ::std::mem::size_of::<Param<'_>>()];static_assert_size!(Param<'_>, 32);
5512 const _: [(); 80] = [(); ::std::mem::size_of::<Pat<'_>>()];static_assert_size!(Pat<'_>, 80);
5513 const _: [(); 56] = [(); ::std::mem::size_of::<PatKind<'_>>()];static_assert_size!(PatKind<'_>, 56);
5514 const _: [(); 40] = [(); ::std::mem::size_of::<Path<'_>>()];static_assert_size!(Path<'_>, 40);
5515 const _: [(); 48] = [(); ::std::mem::size_of::<PathSegment<'_>>()];static_assert_size!(PathSegment<'_>, 48);
5516 const _: [(); 24] = [(); ::std::mem::size_of::<QPath<'_>>()];static_assert_size!(QPath<'_>, 24);
5517 const _: [(); 12] = [(); ::std::mem::size_of::<Res>()];static_assert_size!(Res, 12);
5518 const _: [(); 32] = [(); ::std::mem::size_of::<Stmt<'_>>()];static_assert_size!(Stmt<'_>, 32);
5519 const _: [(); 16] = [(); ::std::mem::size_of::<StmtKind<'_>>()];static_assert_size!(StmtKind<'_>, 16);
5520 const _: [(); 48] = [(); ::std::mem::size_of::<TraitImplHeader<'_>>()];static_assert_size!(TraitImplHeader<'_>, 48);
5521 const _: [(); 88] = [(); ::std::mem::size_of::<TraitItem<'_>>()];static_assert_size!(TraitItem<'_>, 88);
5522 const _: [(); 48] = [(); ::std::mem::size_of::<TraitItemKind<'_>>()];static_assert_size!(TraitItemKind<'_>, 48);
5523 const _: [(); 48] = [(); ::std::mem::size_of::<Ty<'_>>()];static_assert_size!(Ty<'_>, 48);
5524 const _: [(); 32] = [(); ::std::mem::size_of::<TyKind<'_>>()];static_assert_size!(TyKind<'_>, 32);
5525 }
5527
5528#[cfg(test)]
5529mod tests;