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::tagged_ptr::TaggedRef;
22use rustc_error_messages::{DiagArgValue, IntoDiagArg};
23use rustc_index::IndexVec;
24use rustc_macros::{Decodable, Encodable, HashStable_Generic};
25use rustc_span::def_id::LocalDefId;
26use rustc_span::{
27 BytePos, DUMMY_SP, DesugaringKind, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, sym,
28};
29use rustc_target::asm::InlineAsmRegOrRegClass;
30use smallvec::SmallVec;
31use thin_vec::ThinVec;
32use tracing::debug;
33
34use crate::attrs::AttributeKind;
35use crate::def::{CtorKind, DefKind, MacroKinds, PerNS, Res};
36use crate::def_id::{DefId, LocalDefIdMap};
37pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId};
38use crate::intravisit::{FnKind, VisitorExt};
39use crate::lints::DelayedLints;
40
41#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AngleBrackets where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
AngleBrackets::Missing => {}
AngleBrackets::Empty => {}
AngleBrackets::Full => {}
}
}
}
};HashStable_Generic)]
42pub enum AngleBrackets {
43 Missing,
45 Empty,
47 Full,
49}
50
51#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LifetimeSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LifetimeSource::Reference => {}
LifetimeSource::Path { angle_brackets: ref __binding_0 } =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
}
LifetimeSource::OutlivesBound => {}
LifetimeSource::PreciseCapturing => {}
LifetimeSource::Other => {}
}
}
}
};HashStable_Generic)]
52pub enum LifetimeSource {
53 Reference,
55
56 Path { angle_brackets: AngleBrackets },
59
60 OutlivesBound,
62
63 PreciseCapturing,
65
66 Other,
73}
74
75#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LifetimeSyntax where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LifetimeSyntax::Implicit => {}
LifetimeSyntax::ExplicitAnonymous => {}
LifetimeSyntax::ExplicitBound => {}
}
}
}
};HashStable_Generic)]
76pub enum LifetimeSyntax {
77 Implicit,
79
80 ExplicitAnonymous,
82
83 ExplicitBound,
85}
86
87impl From<Ident> for LifetimeSyntax {
88 fn from(ident: Ident) -> Self {
89 let name = ident.name;
90
91 if name == sym::empty {
92 {
::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");
93 } else if name == kw::UnderscoreLifetime {
94 LifetimeSyntax::ExplicitAnonymous
95 } else {
96 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('\''));
97 LifetimeSyntax::ExplicitBound
98 }
99 }
100}
101
102#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Lifetime where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
153#[repr(align(4))]
161pub struct Lifetime {
162 #[stable_hasher(ignore)]
163 pub hir_id: HirId,
164
165 pub ident: Ident,
169
170 pub kind: LifetimeKind,
172
173 pub source: LifetimeSource,
176
177 pub syntax: LifetimeSyntax,
180}
181
182#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ParamName where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ParamName::Plain(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ParamName::Error(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ParamName::Fresh => {}
}
}
}
};HashStable_Generic)]
183pub enum ParamName {
184 Plain(Ident),
186
187 Error(Ident),
193
194 Fresh,
209}
210
211impl ParamName {
212 pub fn ident(&self) -> Ident {
213 match *self {
214 ParamName::Plain(ident) | ParamName::Error(ident) => ident,
215 ParamName::Fresh => Ident::with_dummy_span(kw::UnderscoreLifetime),
216 }
217 }
218}
219
220#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LifetimeKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LifetimeKind::Param(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
LifetimeKind::ImplicitObjectLifetimeDefault => {}
LifetimeKind::Error(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
LifetimeKind::Infer => {}
LifetimeKind::Static => {}
}
}
}
};HashStable_Generic)]
221pub enum LifetimeKind {
222 Param(LocalDefId),
224
225 ImplicitObjectLifetimeDefault,
237
238 Error(ErrorGuaranteed),
241
242 Infer,
246
247 Static,
249}
250
251impl LifetimeKind {
252 fn is_elided(&self) -> bool {
253 match self {
254 LifetimeKind::ImplicitObjectLifetimeDefault | LifetimeKind::Infer => true,
255
256 LifetimeKind::Error(..) | LifetimeKind::Param(..) | LifetimeKind::Static => false,
261 }
262 }
263}
264
265impl fmt::Display for Lifetime {
266 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
267 self.ident.name.fmt(f)
268 }
269}
270
271impl Lifetime {
272 pub fn new(
273 hir_id: HirId,
274 ident: Ident,
275 kind: LifetimeKind,
276 source: LifetimeSource,
277 syntax: LifetimeSyntax,
278 ) -> Lifetime {
279 let lifetime = Lifetime { hir_id, ident, kind, source, syntax };
280
281 #[cfg(debug_assertions)]
283 match (lifetime.is_elided(), lifetime.is_anonymous()) {
284 (false, false) => {} (false, true) => {} (true, true) => {} (true, false) => { ::core::panicking::panic_fmt(format_args!("bad Lifetime")); }panic!("bad Lifetime"),
288 }
289
290 lifetime
291 }
292
293 pub fn is_elided(&self) -> bool {
294 self.kind.is_elided()
295 }
296
297 pub fn is_anonymous(&self) -> bool {
298 self.ident.name == kw::UnderscoreLifetime
299 }
300
301 pub fn is_implicit(&self) -> bool {
302 #[allow(non_exhaustive_omitted_patterns)] match self.syntax {
LifetimeSyntax::Implicit => true,
_ => false,
}matches!(self.syntax, LifetimeSyntax::Implicit)
303 }
304
305 pub fn is_static(&self) -> bool {
306 self.kind == LifetimeKind::Static
307 }
308
309 pub fn suggestion(&self, new_lifetime: &str) -> (Span, String) {
310 use LifetimeSource::*;
311 use LifetimeSyntax::*;
312
313 if true {
if !new_lifetime.starts_with('\'') {
::core::panicking::panic("assertion failed: new_lifetime.starts_with(\'\\\'\')")
};
};debug_assert!(new_lifetime.starts_with('\''));
314
315 match (self.syntax, self.source) {
316 (ExplicitBound | ExplicitAnonymous, _) => (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", new_lifetime))
})format!("{new_lifetime}")),
318
319 (Implicit, Path { angle_brackets: AngleBrackets::Full }) => {
321 (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}, ", new_lifetime))
})format!("{new_lifetime}, "))
322 }
323
324 (Implicit, Path { angle_brackets: AngleBrackets::Empty }) => {
326 (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", new_lifetime))
})format!("{new_lifetime}"))
327 }
328
329 (Implicit, Path { angle_brackets: AngleBrackets::Missing }) => {
331 (self.ident.span.shrink_to_hi(), ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<{0}>", new_lifetime))
})format!("<{new_lifetime}>"))
332 }
333
334 (Implicit, Reference) => (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", new_lifetime))
})format!("{new_lifetime} ")),
336
337 (Implicit, source) => {
338 {
::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:?}")
339 }
340 }
341 }
342}
343
344#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Path<'hir, R> where __CTX: crate::HashStableContext,
R: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Path {
span: ref __binding_0,
res: ref __binding_1,
segments: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
348pub struct Path<'hir, R = Res> {
349 pub span: Span,
350 pub res: R,
352 pub segments: &'hir [PathSegment<'hir>],
354}
355
356pub type UsePath<'hir> = Path<'hir, PerNS<Option<Res>>>;
358
359impl Path<'_> {
360 pub fn is_global(&self) -> bool {
361 self.segments.first().is_some_and(|segment| segment.ident.name == kw::PathRoot)
362 }
363}
364
365#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PathSegment<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "PathSegment",
"ident", &self.ident, "hir_id", &self.hir_id, "res", &self.res,
"args", &self.args, "infer_args", &&self.infer_args)
}
}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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PathSegment<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{}
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
368pub struct PathSegment<'hir> {
369 pub ident: Ident,
371 #[stable_hasher(ignore)]
372 pub hir_id: HirId,
373 pub res: Res,
374
375 pub args: Option<&'hir GenericArgs<'hir>>,
381
382 pub infer_args: bool,
387}
388
389impl<'hir> PathSegment<'hir> {
390 pub fn new(ident: Ident, hir_id: HirId, res: Res) -> PathSegment<'hir> {
392 PathSegment { ident, hir_id, res, infer_args: true, args: None }
393 }
394
395 pub fn invalid() -> Self {
396 Self::new(Ident::dummy(), HirId::INVALID, Res::Err)
397 }
398
399 pub fn args(&self) -> &GenericArgs<'hir> {
400 if let Some(ref args) = self.args {
401 args
402 } else {
403 const DUMMY: &GenericArgs<'_> = &GenericArgs::none();
404 DUMMY
405 }
406 }
407}
408
409#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstItemRhs<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ConstItemRhs::Body(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstItemRhs::TypeConst(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
410pub enum ConstItemRhs<'hir> {
411 Body(BodyId),
412 TypeConst(&'hir ConstArg<'hir>),
413}
414
415impl<'hir> ConstItemRhs<'hir> {
416 pub fn hir_id(&self) -> HirId {
417 match self {
418 ConstItemRhs::Body(body_id) => body_id.hir_id,
419 ConstItemRhs::TypeConst(ct_arg) => ct_arg.hir_id,
420 }
421 }
422
423 pub fn span<'tcx>(&self, tcx: impl crate::intravisit::HirTyCtxt<'tcx>) -> Span {
424 match self {
425 ConstItemRhs::Body(body_id) => tcx.hir_body(*body_id).value.span,
426 ConstItemRhs::TypeConst(ct_arg) => ct_arg.span,
427 }
428 }
429}
430
431#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstArg<'hir, Unambig> where __CTX: crate::HashStableContext,
Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ConstArg {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
445#[repr(C)]
446pub struct ConstArg<'hir, Unambig = ()> {
447 #[stable_hasher(ignore)]
448 pub hir_id: HirId,
449 pub kind: ConstArgKind<'hir, Unambig>,
450 pub span: Span,
451}
452
453impl<'hir> ConstArg<'hir, AmbigArg> {
454 pub fn as_unambig_ct(&self) -> &ConstArg<'hir> {
465 let ptr = self as *const ConstArg<'hir, AmbigArg> as *const ConstArg<'hir, ()>;
468 unsafe { &*ptr }
469 }
470}
471
472impl<'hir> ConstArg<'hir> {
473 pub fn try_as_ambig_ct(&self) -> Option<&ConstArg<'hir, AmbigArg>> {
479 if let ConstArgKind::Infer(()) = self.kind {
480 return None;
481 }
482
483 let ptr = self as *const ConstArg<'hir> as *const ConstArg<'hir, AmbigArg>;
487 Some(unsafe { &*ptr })
488 }
489}
490
491impl<'hir, Unambig> ConstArg<'hir, Unambig> {
492 pub fn anon_const_hir_id(&self) -> Option<HirId> {
493 match self.kind {
494 ConstArgKind::Anon(ac) => Some(ac.hir_id),
495 _ => None,
496 }
497 }
498}
499
500#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstArgKind<'hir, Unambig> where __CTX: crate::HashStableContext,
Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ConstArgKind::Tup(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Path(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Anon(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Struct(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ConstArgKind::TupleCall(ref __binding_0, ref __binding_1) =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Array(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Error(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Infer(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Literal {
lit: ref __binding_0, negated: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
502#[repr(u8, C)]
503pub enum ConstArgKind<'hir, Unambig = ()> {
504 Tup(&'hir [&'hir ConstArg<'hir, Unambig>]),
505 Path(QPath<'hir>),
511 Anon(&'hir AnonConst),
512 Struct(QPath<'hir>, &'hir [&'hir ConstArgExprField<'hir>]),
514 TupleCall(QPath<'hir>, &'hir [&'hir ConstArg<'hir>]),
516 Array(&'hir ConstArgArrayExpr<'hir>),
518 Error(ErrorGuaranteed),
520 Infer(Unambig),
523 Literal {
524 lit: LitKind,
525 negated: bool,
526 },
527}
528
529#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstArgExprField<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ConstArgExprField {
hir_id: ref __binding_0,
span: ref __binding_1,
field: ref __binding_2,
expr: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
530pub struct ConstArgExprField<'hir> {
531 pub hir_id: HirId,
532 pub span: Span,
533 pub field: Ident,
534 pub expr: &'hir ConstArg<'hir>,
535}
536
537#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstArgArrayExpr<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ConstArgArrayExpr {
span: ref __binding_0, elems: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
538pub struct ConstArgArrayExpr<'hir> {
539 pub span: Span,
540 pub elems: &'hir [&'hir ConstArg<'hir>],
541}
542
543#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for InferArg where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
InferArg { hir_id: ref __binding_0, span: ref __binding_1 }
=> {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
544pub struct InferArg {
545 #[stable_hasher(ignore)]
546 pub hir_id: HirId,
547 pub span: Span,
548}
549
550impl InferArg {
551 pub fn to_ty(&self) -> Ty<'static> {
552 Ty { kind: TyKind::Infer(()), span: self.span, hir_id: self.hir_id }
553 }
554}
555
556#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericArg<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericArg::Lifetime(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericArg::Type(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericArg::Const(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericArg::Infer(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
557pub enum GenericArg<'hir> {
558 Lifetime(&'hir Lifetime),
559 Type(&'hir Ty<'hir, AmbigArg>),
560 Const(&'hir ConstArg<'hir, AmbigArg>),
561 Infer(InferArg),
571}
572
573impl GenericArg<'_> {
574 pub fn span(&self) -> Span {
575 match self {
576 GenericArg::Lifetime(l) => l.ident.span,
577 GenericArg::Type(t) => t.span,
578 GenericArg::Const(c) => c.span,
579 GenericArg::Infer(i) => i.span,
580 }
581 }
582
583 pub fn hir_id(&self) -> HirId {
584 match self {
585 GenericArg::Lifetime(l) => l.hir_id,
586 GenericArg::Type(t) => t.hir_id,
587 GenericArg::Const(c) => c.hir_id,
588 GenericArg::Infer(i) => i.hir_id,
589 }
590 }
591
592 pub fn descr(&self) -> &'static str {
593 match self {
594 GenericArg::Lifetime(_) => "lifetime",
595 GenericArg::Type(_) => "type",
596 GenericArg::Const(_) => "constant",
597 GenericArg::Infer(_) => "placeholder",
598 }
599 }
600
601 pub fn to_ord(&self) -> ast::ParamKindOrd {
602 match self {
603 GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime,
604 GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => {
605 ast::ParamKindOrd::TypeOrConst
606 }
607 }
608 }
609
610 pub fn is_ty_or_const(&self) -> bool {
611 match self {
612 GenericArg::Lifetime(_) => false,
613 GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => true,
614 }
615 }
616}
617
618#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericArgs<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
GenericArgs {
args: ref __binding_0,
constraints: ref __binding_1,
parenthesized: ref __binding_2,
span_ext: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
620pub struct GenericArgs<'hir> {
621 pub args: &'hir [GenericArg<'hir>],
623 pub constraints: &'hir [AssocItemConstraint<'hir>],
625 pub parenthesized: GenericArgsParentheses,
630 pub span_ext: Span,
643}
644
645impl<'hir> GenericArgs<'hir> {
646 pub const fn none() -> Self {
647 Self {
648 args: &[],
649 constraints: &[],
650 parenthesized: GenericArgsParentheses::No,
651 span_ext: DUMMY_SP,
652 }
653 }
654
655 pub fn paren_sugar_inputs_output(&self) -> Option<(&[Ty<'hir>], &Ty<'hir>)> {
660 if self.parenthesized != GenericArgsParentheses::ParenSugar {
661 return None;
662 }
663
664 let inputs = self
665 .args
666 .iter()
667 .find_map(|arg| {
668 let GenericArg::Type(ty) = arg else { return None };
669 let TyKind::Tup(tys) = &ty.kind else { return None };
670 Some(tys)
671 })
672 .unwrap();
673
674 Some((inputs, self.paren_sugar_output_inner()))
675 }
676
677 pub fn paren_sugar_output(&self) -> Option<&Ty<'hir>> {
682 (self.parenthesized == GenericArgsParentheses::ParenSugar)
683 .then(|| self.paren_sugar_output_inner())
684 }
685
686 fn paren_sugar_output_inner(&self) -> &Ty<'hir> {
687 let [constraint] = self.constraints.try_into().unwrap();
688 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);
689 constraint.ty().unwrap()
690 }
691
692 pub fn has_err(&self) -> Option<ErrorGuaranteed> {
693 self.args
694 .iter()
695 .find_map(|arg| {
696 let GenericArg::Type(ty) = arg else { return None };
697 let TyKind::Err(guar) = ty.kind else { return None };
698 Some(guar)
699 })
700 .or_else(|| {
701 self.constraints.iter().find_map(|constraint| {
702 let TyKind::Err(guar) = constraint.ty()?.kind else { return None };
703 Some(guar)
704 })
705 })
706 }
707
708 #[inline]
709 pub fn num_lifetime_params(&self) -> usize {
710 self.args.iter().filter(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
711 }
712
713 #[inline]
714 pub fn has_lifetime_params(&self) -> bool {
715 self.args.iter().any(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_)))
716 }
717
718 #[inline]
719 pub fn num_generic_params(&self) -> usize {
722 self.args.iter().filter(|arg| !#[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
723 }
724
725 pub fn span(&self) -> Option<Span> {
731 let span_ext = self.span_ext()?;
732 Some(span_ext.with_lo(span_ext.lo() + BytePos(1)).with_hi(span_ext.hi() - BytePos(1)))
733 }
734
735 pub fn span_ext(&self) -> Option<Span> {
737 Some(self.span_ext).filter(|span| !span.is_empty())
738 }
739
740 pub fn is_empty(&self) -> bool {
741 self.args.is_empty()
742 }
743}
744
745#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for GenericArgsParentheses where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericArgsParentheses::No => {}
GenericArgsParentheses::ReturnTypeNotation => {}
GenericArgsParentheses::ParenSugar => {}
}
}
}
};HashStable_Generic)]
746pub enum GenericArgsParentheses {
747 No,
748 ReturnTypeNotation,
751 ParenSugar,
753}
754
755#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for TraitBoundModifiers where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitBoundModifiers {
constness: ref __binding_0, polarity: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
757pub struct TraitBoundModifiers {
758 pub constness: BoundConstness,
759 pub polarity: BoundPolarity,
760}
761
762impl TraitBoundModifiers {
763 pub const NONE: Self =
764 TraitBoundModifiers { constness: BoundConstness::Never, polarity: BoundPolarity::Positive };
765}
766
767#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericBound<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericBound::Trait(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericBound::Outlives(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericBound::Use(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
768pub enum GenericBound<'hir> {
769 Trait(PolyTraitRef<'hir>),
770 Outlives(&'hir Lifetime),
771 Use(&'hir [PreciseCapturingArg<'hir>], Span),
772}
773
774impl GenericBound<'_> {
775 pub fn trait_ref(&self) -> Option<&TraitRef<'_>> {
776 match self {
777 GenericBound::Trait(data) => Some(&data.trait_ref),
778 _ => None,
779 }
780 }
781
782 pub fn span(&self) -> Span {
783 match self {
784 GenericBound::Trait(t, ..) => t.span,
785 GenericBound::Outlives(l) => l.ident.span,
786 GenericBound::Use(_, span) => *span,
787 }
788 }
789}
790
791pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>];
792
793#[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> {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
}
}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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for MissingLifetimeKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
MissingLifetimeKind::Underscore => {}
MissingLifetimeKind::Ampersand => {}
MissingLifetimeKind::Comma => {}
MissingLifetimeKind::Brackets => {}
}
}
}
};HashStable_Generic, #[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)]
794pub enum MissingLifetimeKind {
795 Underscore,
797 Ampersand,
799 Comma,
801 Brackets,
803}
804
805#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LifetimeParamKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LifetimeParamKind::Explicit => {}
LifetimeParamKind::Elided(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
LifetimeParamKind::Error => {}
}
}
}
};HashStable_Generic)]
806pub enum LifetimeParamKind {
807 Explicit,
810
811 Elided(MissingLifetimeKind),
814
815 Error,
817}
818
819#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericParamKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericParamKind::Lifetime { kind: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericParamKind::Type {
default: ref __binding_0, synthetic: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
GenericParamKind::Const {
ty: ref __binding_0, default: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
820pub enum GenericParamKind<'hir> {
821 Lifetime {
823 kind: LifetimeParamKind,
824 },
825 Type {
826 default: Option<&'hir Ty<'hir>>,
827 synthetic: bool,
828 },
829 Const {
830 ty: &'hir Ty<'hir>,
831 default: Option<&'hir ConstArg<'hir>>,
833 },
834}
835
836#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericParam<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
{ __binding_7.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
837pub struct GenericParam<'hir> {
838 #[stable_hasher(ignore)]
839 pub hir_id: HirId,
840 pub def_id: LocalDefId,
841 pub name: ParamName,
842 pub span: Span,
843 pub pure_wrt_drop: bool,
844 pub kind: GenericParamKind<'hir>,
845 pub colon_span: Option<Span>,
846 pub source: GenericParamSource,
847}
848
849impl<'hir> GenericParam<'hir> {
850 pub fn is_impl_trait(&self) -> bool {
854 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Type { synthetic: true, .. } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Type { synthetic: true, .. })
855 }
856
857 pub fn is_elided_lifetime(&self) -> bool {
861 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) })
862 }
863
864 pub fn is_lifetime(&self) -> bool {
865 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Lifetime { .. } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Lifetime { .. })
866 }
867}
868
869#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for GenericParamSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericParamSource::Generics => {}
GenericParamSource::Binder => {}
}
}
}
};HashStable_Generic)]
876pub enum GenericParamSource {
877 Generics,
879 Binder,
881}
882
883#[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)]
884pub struct GenericParamCount {
885 pub lifetimes: usize,
886 pub types: usize,
887 pub consts: usize,
888 pub infer: usize,
889}
890
891#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Generics<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
894pub struct Generics<'hir> {
895 pub params: &'hir [GenericParam<'hir>],
896 pub predicates: &'hir [WherePredicate<'hir>],
897 pub has_where_clause_predicates: bool,
898 pub where_clause_span: Span,
899 pub span: Span,
900}
901
902impl<'hir> Generics<'hir> {
903 pub const fn empty() -> &'hir Generics<'hir> {
904 const NOPE: Generics<'_> = Generics {
905 params: &[],
906 predicates: &[],
907 has_where_clause_predicates: false,
908 where_clause_span: DUMMY_SP,
909 span: DUMMY_SP,
910 };
911 &NOPE
912 }
913
914 pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'hir>> {
915 self.params.iter().find(|¶m| name == param.name.ident().name)
916 }
917
918 pub fn span_for_lifetime_suggestion(&self) -> Option<Span> {
920 if let Some(first) = self.params.first()
921 && self.span.contains(first.span)
922 {
923 Some(first.span.shrink_to_lo())
926 } else {
927 None
928 }
929 }
930
931 pub fn span_for_param_suggestion(&self) -> Option<Span> {
933 self.params.iter().any(|p| self.span.contains(p.span)).then(|| {
934 self.span.with_lo(self.span.hi() - BytePos(1)).shrink_to_lo()
937 })
938 }
939
940 pub fn tail_span_for_predicate_suggestion(&self) -> Span {
943 let end = self.where_clause_span.shrink_to_hi();
944 if self.has_where_clause_predicates {
945 self.predicates
946 .iter()
947 .rfind(|&p| p.kind.in_where_clause())
948 .map_or(end, |p| p.span)
949 .shrink_to_hi()
950 .to(end)
951 } else {
952 end
953 }
954 }
955
956 pub fn add_where_or_trailing_comma(&self) -> &'static str {
957 if self.has_where_clause_predicates {
958 ","
959 } else if self.where_clause_span.is_empty() {
960 " where"
961 } else {
962 ""
964 }
965 }
966
967 pub fn bounds_for_param(
968 &self,
969 param_def_id: LocalDefId,
970 ) -> impl Iterator<Item = &WhereBoundPredicate<'hir>> {
971 self.predicates.iter().filter_map(move |pred| match pred.kind {
972 WherePredicateKind::BoundPredicate(bp)
973 if bp.is_param_bound(param_def_id.to_def_id()) =>
974 {
975 Some(bp)
976 }
977 _ => None,
978 })
979 }
980
981 pub fn outlives_for_param(
982 &self,
983 param_def_id: LocalDefId,
984 ) -> impl Iterator<Item = &WhereRegionPredicate<'_>> {
985 self.predicates.iter().filter_map(move |pred| match pred.kind {
986 WherePredicateKind::RegionPredicate(rp) if rp.is_param_bound(param_def_id) => Some(rp),
987 _ => None,
988 })
989 }
990
991 pub fn bounds_span_for_suggestions(
1002 &self,
1003 param_def_id: LocalDefId,
1004 ) -> Option<(Span, Option<Span>)> {
1005 self.bounds_for_param(param_def_id).flat_map(|bp| bp.bounds.iter().rev()).find_map(
1006 |bound| {
1007 let span_for_parentheses = if let Some(trait_ref) = bound.trait_ref()
1008 && let [.., segment] = trait_ref.path.segments
1009 && let Some(ret_ty) = segment.args().paren_sugar_output()
1010 && let ret_ty = ret_ty.peel_refs()
1011 && let TyKind::TraitObject(_, tagged_ptr) = ret_ty.kind
1012 && let TraitObjectSyntax::Dyn = tagged_ptr.tag()
1013 && ret_ty.span.can_be_used_for_suggestions()
1014 {
1015 Some(ret_ty.span)
1016 } else {
1017 None
1018 };
1019
1020 span_for_parentheses.map_or_else(
1021 || {
1022 let bs = bound.span();
1025 bs.from_expansion().not().then(|| (bs.shrink_to_hi(), None))
1030 },
1031 |span| Some((span.shrink_to_hi(), Some(span.shrink_to_lo()))),
1032 )
1033 },
1034 )
1035 }
1036
1037 pub fn span_for_predicate_removal(&self, pos: usize) -> Span {
1038 let predicate = &self.predicates[pos];
1039 let span = predicate.span;
1040
1041 if !predicate.kind.in_where_clause() {
1042 return span;
1045 }
1046
1047 if pos < self.predicates.len() - 1 {
1049 let next_pred = &self.predicates[pos + 1];
1050 if next_pred.kind.in_where_clause() {
1051 return span.until(next_pred.span);
1054 }
1055 }
1056
1057 if pos > 0 {
1058 let prev_pred = &self.predicates[pos - 1];
1059 if prev_pred.kind.in_where_clause() {
1060 return prev_pred.span.shrink_to_hi().to(span);
1063 }
1064 }
1065
1066 self.where_clause_span
1070 }
1071
1072 pub fn span_for_bound_removal(&self, predicate_pos: usize, bound_pos: usize) -> Span {
1073 let predicate = &self.predicates[predicate_pos];
1074 let bounds = predicate.kind.bounds();
1075
1076 if bounds.len() == 1 {
1077 return self.span_for_predicate_removal(predicate_pos);
1078 }
1079
1080 let bound_span = bounds[bound_pos].span();
1081 if bound_pos < bounds.len() - 1 {
1082 bound_span.to(bounds[bound_pos + 1].span().shrink_to_lo())
1088 } else {
1089 bound_span.with_lo(bounds[bound_pos - 1].span().hi())
1095 }
1096 }
1097}
1098
1099#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
WherePredicate<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
WherePredicate {
hir_id: ref __binding_0,
span: ref __binding_1,
kind: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1101pub struct WherePredicate<'hir> {
1102 #[stable_hasher(ignore)]
1103 pub hir_id: HirId,
1104 pub span: Span,
1105 pub kind: &'hir WherePredicateKind<'hir>,
1106}
1107
1108#[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),
WherePredicateKind::EqPredicate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"EqPredicate", &__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>>;
let _: ::core::clone::AssertParamIsClone<WhereEqPredicate<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WherePredicateKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
WherePredicateKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
WherePredicateKind::BoundPredicate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
WherePredicateKind::RegionPredicate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
WherePredicateKind::EqPredicate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1110pub enum WherePredicateKind<'hir> {
1111 BoundPredicate(WhereBoundPredicate<'hir>),
1113 RegionPredicate(WhereRegionPredicate<'hir>),
1115 EqPredicate(WhereEqPredicate<'hir>),
1117}
1118
1119impl<'hir> WherePredicateKind<'hir> {
1120 pub fn in_where_clause(&self) -> bool {
1121 match self {
1122 WherePredicateKind::BoundPredicate(p) => p.origin == PredicateOrigin::WhereClause,
1123 WherePredicateKind::RegionPredicate(p) => p.in_where_clause,
1124 WherePredicateKind::EqPredicate(_) => false,
1125 }
1126 }
1127
1128 pub fn bounds(&self) -> GenericBounds<'hir> {
1129 match self {
1130 WherePredicateKind::BoundPredicate(p) => p.bounds,
1131 WherePredicateKind::RegionPredicate(p) => p.bounds,
1132 WherePredicateKind::EqPredicate(_) => &[],
1133 }
1134 }
1135}
1136
1137#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for PredicateOrigin where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
PredicateOrigin::WhereClause => {}
PredicateOrigin::GenericParam => {}
PredicateOrigin::ImplTrait => {}
}
}
}
};HashStable_Generic, #[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)]
1138pub enum PredicateOrigin {
1139 WhereClause,
1140 GenericParam,
1141 ImplTrait,
1142}
1143
1144#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
WhereBoundPredicate<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1146pub struct WhereBoundPredicate<'hir> {
1147 pub origin: PredicateOrigin,
1149 pub bound_generic_params: &'hir [GenericParam<'hir>],
1151 pub bounded_ty: &'hir Ty<'hir>,
1153 pub bounds: GenericBounds<'hir>,
1155}
1156
1157impl<'hir> WhereBoundPredicate<'hir> {
1158 pub fn is_param_bound(&self, param_def_id: DefId) -> bool {
1160 self.bounded_ty.as_generic_param().is_some_and(|(def_id, _)| def_id == param_def_id)
1161 }
1162}
1163
1164#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
WhereRegionPredicate<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
WhereRegionPredicate {
in_where_clause: ref __binding_0,
lifetime: ref __binding_1,
bounds: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1166pub struct WhereRegionPredicate<'hir> {
1167 pub in_where_clause: bool,
1168 pub lifetime: &'hir Lifetime,
1169 pub bounds: GenericBounds<'hir>,
1170}
1171
1172impl<'hir> WhereRegionPredicate<'hir> {
1173 fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
1175 self.lifetime.kind == LifetimeKind::Param(param_def_id)
1176 }
1177}
1178
1179#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
WhereEqPredicate<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
WhereEqPredicate {
lhs_ty: ref __binding_0, rhs_ty: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1181pub struct WhereEqPredicate<'hir> {
1182 pub lhs_ty: &'hir Ty<'hir>,
1183 pub rhs_ty: &'hir Ty<'hir>,
1184}
1185
1186#[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)]
1190pub struct ParentedNode<'tcx> {
1191 pub parent: ItemLocalId,
1192 pub node: Node<'tcx>,
1193}
1194
1195#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AttrArgs where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
AttrArgs::Empty => {}
AttrArgs::Delimited(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
AttrArgs::Eq {
eq_span: ref __binding_0, expr: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, 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)]
1197pub enum AttrArgs {
1198 Empty,
1200 Delimited(DelimArgs),
1202 Eq {
1204 eq_span: Span,
1206 expr: MetaItemLit,
1208 },
1209}
1210
1211#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AttrPath where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
AttrPath { segments: ref __binding_0, span: ref __binding_1
} => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, 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)]
1212pub struct AttrPath {
1213 pub segments: Box<[Symbol]>,
1214 pub span: Span,
1215}
1216
1217impl IntoDiagArg for AttrPath {
1218 fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>) -> DiagArgValue {
1219 self.to_string().into_diag_arg(path)
1220 }
1221}
1222
1223impl AttrPath {
1224 pub fn from_ast(path: &ast::Path, lower_span: impl Copy + Fn(Span) -> Span) -> Self {
1225 AttrPath {
1226 segments: path
1227 .segments
1228 .iter()
1229 .map(|i| i.ident.name)
1230 .collect::<Vec<_>>()
1231 .into_boxed_slice(),
1232 span: lower_span(path.span),
1233 }
1234 }
1235}
1236
1237impl fmt::Display for AttrPath {
1238 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1239 f.write_fmt(format_args!("{0}",
join_path_idents(self.segments.iter().map(|i|
Ident { name: *i, span: DUMMY_SP }))))write!(
1240 f,
1241 "{}",
1242 join_path_idents(self.segments.iter().map(|i| Ident { name: *i, span: DUMMY_SP }))
1243 )
1244 }
1245}
1246
1247#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AttrItem where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, 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)]
1248pub struct AttrItem {
1249 pub path: AttrPath,
1251 pub args: AttrArgs,
1252 pub id: HashIgnoredAttrId,
1253 pub style: AttrStyle,
1256 pub span: Span,
1258}
1259
1260#[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)]
1263pub struct HashIgnoredAttrId {
1264 pub attr_id: AttrId,
1265}
1266
1267#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Attribute where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Attribute::Parsed(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Attribute::Unparsed(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1268pub enum Attribute {
1269 Parsed(AttributeKind),
1275
1276 Unparsed(Box<AttrItem>),
1279}
1280
1281impl Attribute {
1282 pub fn get_normal_item(&self) -> &AttrItem {
1283 match &self {
1284 Attribute::Unparsed(normal) => &normal,
1285 _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1286 }
1287 }
1288
1289 pub fn unwrap_normal_item(self) -> AttrItem {
1290 match self {
1291 Attribute::Unparsed(normal) => *normal,
1292 _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1293 }
1294 }
1295
1296 pub fn value_lit(&self) -> Option<&MetaItemLit> {
1297 match &self {
1298 Attribute::Unparsed(n) => match n.as_ref() {
1299 AttrItem { args: AttrArgs::Eq { eq_span: _, expr }, .. } => Some(expr),
1300 _ => None,
1301 },
1302 _ => None,
1303 }
1304 }
1305
1306 pub fn is_parsed_attr(&self) -> bool {
1307 match self {
1308 Attribute::Parsed(_) => true,
1309 Attribute::Unparsed(_) => false,
1310 }
1311 }
1312}
1313
1314impl AttributeExt for Attribute {
1315 #[inline]
1316 fn id(&self) -> AttrId {
1317 match &self {
1318 Attribute::Unparsed(u) => u.id.attr_id,
1319 _ => ::core::panicking::panic("explicit panic")panic!(),
1320 }
1321 }
1322
1323 #[inline]
1324 fn meta_item_list(&self) -> Option<ThinVec<ast::MetaItemInner>> {
1325 match &self {
1326 Attribute::Unparsed(n) => match n.as_ref() {
1327 AttrItem { args: AttrArgs::Delimited(d), .. } => {
1328 ast::MetaItemKind::list_from_tokens(d.tokens.clone())
1329 }
1330 _ => None,
1331 },
1332 _ => None,
1333 }
1334 }
1335
1336 #[inline]
1337 fn value_str(&self) -> Option<Symbol> {
1338 self.value_lit().and_then(|x| x.value_str())
1339 }
1340
1341 #[inline]
1342 fn value_span(&self) -> Option<Span> {
1343 self.value_lit().map(|i| i.span)
1344 }
1345
1346 #[inline]
1348 fn name(&self) -> Option<Symbol> {
1349 match &self {
1350 Attribute::Unparsed(n) => {
1351 if let [ident] = n.path.segments.as_ref() {
1352 Some(*ident)
1353 } else {
1354 None
1355 }
1356 }
1357 _ => None,
1358 }
1359 }
1360
1361 #[inline]
1362 fn path_matches(&self, name: &[Symbol]) -> bool {
1363 match &self {
1364 Attribute::Unparsed(n) => n.path.segments.iter().eq(name),
1365 _ => false,
1366 }
1367 }
1368
1369 #[inline]
1370 fn is_doc_comment(&self) -> Option<Span> {
1371 if let Attribute::Parsed(AttributeKind::DocComment { span, .. }) = self {
1372 Some(*span)
1373 } else {
1374 None
1375 }
1376 }
1377
1378 #[inline]
1379 fn span(&self) -> Span {
1380 match &self {
1381 Attribute::Unparsed(u) => u.span,
1382 Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
1384 Attribute::Parsed(AttributeKind::Deprecated { span, .. }) => *span,
1385 Attribute::Parsed(AttributeKind::CfgTrace(cfgs)) => cfgs[0].1,
1386 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:?}"),
1387 }
1388 }
1389
1390 #[inline]
1391 fn is_word(&self) -> bool {
1392 match &self {
1393 Attribute::Unparsed(n) => {
1394 #[allow(non_exhaustive_omitted_patterns)] match n.args {
AttrArgs::Empty => true,
_ => false,
}matches!(n.args, AttrArgs::Empty)
1395 }
1396 _ => false,
1397 }
1398 }
1399
1400 #[inline]
1401 fn symbol_path(&self) -> Option<SmallVec<[Symbol; 1]>> {
1402 match &self {
1403 Attribute::Unparsed(n) => Some(n.path.segments.iter().copied().collect()),
1404 _ => None,
1405 }
1406 }
1407
1408 fn path_span(&self) -> Option<Span> {
1409 match &self {
1410 Attribute::Unparsed(attr) => Some(attr.path.span),
1411 Attribute::Parsed(_) => None,
1412 }
1413 }
1414
1415 #[inline]
1416 fn doc_str(&self) -> Option<Symbol> {
1417 match &self {
1418 Attribute::Parsed(AttributeKind::DocComment { comment, .. }) => Some(*comment),
1419 _ => None,
1420 }
1421 }
1422
1423 #[inline]
1424 fn deprecation_note(&self) -> Option<Ident> {
1425 match &self {
1426 Attribute::Parsed(AttributeKind::Deprecated { deprecation, .. }) => deprecation.note,
1427 _ => None,
1428 }
1429 }
1430
1431 fn is_automatically_derived_attr(&self) -> bool {
1432 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)) => true,
_ => false,
}matches!(self, Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)))
1433 }
1434
1435 #[inline]
1436 fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1437 match &self {
1438 Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => {
1439 Some((*comment, *kind))
1440 }
1441 _ => None,
1442 }
1443 }
1444
1445 fn doc_resolution_scope(&self) -> Option<AttrStyle> {
1446 match self {
1447 Attribute::Parsed(AttributeKind::DocComment { style, .. }) => Some(*style),
1448 Attribute::Unparsed(attr) if self.has_name(sym::doc) && self.value_str().is_some() => {
1449 Some(attr.style)
1450 }
1451 _ => None,
1452 }
1453 }
1454
1455 fn is_proc_macro_attr(&self) -> bool {
1456 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::ProcMacro(..) |
AttributeKind::ProcMacroAttribute(..) |
AttributeKind::ProcMacroDerive { .. }) => true,
_ => false,
}matches!(
1457 self,
1458 Attribute::Parsed(
1459 AttributeKind::ProcMacro(..)
1460 | AttributeKind::ProcMacroAttribute(..)
1461 | AttributeKind::ProcMacroDerive { .. }
1462 )
1463 )
1464 }
1465
1466 fn is_doc_hidden(&self) -> bool {
1467 #[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())
1468 }
1469
1470 fn is_doc_keyword_or_attribute(&self) -> bool {
1471 #[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())
1472 }
1473
1474 fn is_rustc_doc_primitive(&self) -> bool {
1475 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::RustcDocPrimitive(..)) => true,
_ => false,
}matches!(self, Attribute::Parsed(AttributeKind::RustcDocPrimitive(..)))
1476 }
1477}
1478
1479impl Attribute {
1481 #[inline]
1482 pub fn id(&self) -> AttrId {
1483 AttributeExt::id(self)
1484 }
1485
1486 #[inline]
1487 pub fn name(&self) -> Option<Symbol> {
1488 AttributeExt::name(self)
1489 }
1490
1491 #[inline]
1492 pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
1493 AttributeExt::meta_item_list(self)
1494 }
1495
1496 #[inline]
1497 pub fn value_str(&self) -> Option<Symbol> {
1498 AttributeExt::value_str(self)
1499 }
1500
1501 #[inline]
1502 pub fn value_span(&self) -> Option<Span> {
1503 AttributeExt::value_span(self)
1504 }
1505
1506 #[inline]
1507 pub fn path_matches(&self, name: &[Symbol]) -> bool {
1508 AttributeExt::path_matches(self, name)
1509 }
1510
1511 #[inline]
1512 pub fn is_doc_comment(&self) -> Option<Span> {
1513 AttributeExt::is_doc_comment(self)
1514 }
1515
1516 #[inline]
1517 pub fn has_name(&self, name: Symbol) -> bool {
1518 AttributeExt::has_name(self, name)
1519 }
1520
1521 #[inline]
1522 pub fn has_any_name(&self, names: &[Symbol]) -> bool {
1523 AttributeExt::has_any_name(self, names)
1524 }
1525
1526 #[inline]
1527 pub fn span(&self) -> Span {
1528 AttributeExt::span(self)
1529 }
1530
1531 #[inline]
1532 pub fn is_word(&self) -> bool {
1533 AttributeExt::is_word(self)
1534 }
1535
1536 #[inline]
1537 pub fn path(&self) -> SmallVec<[Symbol; 1]> {
1538 AttributeExt::path(self)
1539 }
1540
1541 #[inline]
1542 pub fn doc_str(&self) -> Option<Symbol> {
1543 AttributeExt::doc_str(self)
1544 }
1545
1546 #[inline]
1547 pub fn is_proc_macro_attr(&self) -> bool {
1548 AttributeExt::is_proc_macro_attr(self)
1549 }
1550
1551 #[inline]
1552 pub fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1553 AttributeExt::doc_str_and_fragment_kind(self)
1554 }
1555}
1556
1557#[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)]
1559pub struct AttributeMap<'tcx> {
1560 pub map: SortedMap<ItemLocalId, &'tcx [Attribute]>,
1561 pub define_opaque: Option<&'tcx [(Span, LocalDefId)]>,
1563 pub opt_hash: Option<Fingerprint>,
1565}
1566
1567impl<'tcx> AttributeMap<'tcx> {
1568 pub const EMPTY: &'static AttributeMap<'static> = &AttributeMap {
1569 map: SortedMap::new(),
1570 opt_hash: Some(Fingerprint::ZERO),
1571 define_opaque: None,
1572 };
1573
1574 #[inline]
1575 pub fn get(&self, id: ItemLocalId) -> &'tcx [Attribute] {
1576 self.map.get(&id).copied().unwrap_or(&[])
1577 }
1578}
1579
1580pub struct OwnerNodes<'tcx> {
1584 pub opt_hash_including_bodies: Option<Fingerprint>,
1587 pub nodes: IndexVec<ItemLocalId, ParentedNode<'tcx>>,
1592 pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>,
1594}
1595
1596impl<'tcx> OwnerNodes<'tcx> {
1597 pub fn node(&self) -> OwnerNode<'tcx> {
1598 self.nodes[ItemLocalId::ZERO].node.as_owner().unwrap()
1600 }
1601}
1602
1603impl fmt::Debug for OwnerNodes<'_> {
1604 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1605 f.debug_struct("OwnerNodes")
1606 .field("node", &self.nodes[ItemLocalId::ZERO])
1608 .field(
1609 "parents",
1610 &fmt::from_fn(|f| {
1611 f.debug_list()
1612 .entries(self.nodes.iter_enumerated().map(|(id, parented_node)| {
1613 fmt::from_fn(move |f| f.write_fmt(format_args!("({1:?}, {0:?})", parented_node.parent, id))write!(f, "({id:?}, {:?})", parented_node.parent))
1614 }))
1615 .finish()
1616 }),
1617 )
1618 .field("bodies", &self.bodies)
1619 .field("opt_hash_including_bodies", &self.opt_hash_including_bodies)
1620 .finish()
1621 }
1622}
1623
1624#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for OwnerInfo<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "OwnerInfo",
"nodes", &self.nodes, "parenting", &self.parenting, "attrs",
&self.attrs, "trait_map", &self.trait_map, "delayed_lints",
&&self.delayed_lints)
}
}Debug, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
OwnerInfo<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
OwnerInfo {
nodes: ref __binding_0,
parenting: ref __binding_1,
attrs: ref __binding_2,
trait_map: ref __binding_3,
delayed_lints: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1626pub struct OwnerInfo<'hir> {
1627 pub nodes: OwnerNodes<'hir>,
1629 pub parenting: LocalDefIdMap<ItemLocalId>,
1631 pub attrs: AttributeMap<'hir>,
1633 pub trait_map: ItemLocalMap<&'hir [TraitCandidate<'hir>]>,
1636
1637 pub delayed_lints: DelayedLints,
1640}
1641
1642impl<'tcx> OwnerInfo<'tcx> {
1643 #[inline]
1644 pub fn node(&self) -> OwnerNode<'tcx> {
1645 self.nodes.node()
1646 }
1647}
1648
1649#[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),
MaybeOwner::Phantom =>
::core::fmt::Formatter::write_str(f, "Phantom"),
}
}
}Debug, const _: () =
{
impl<'tcx, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
MaybeOwner<'tcx> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
MaybeOwner::Owner(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
MaybeOwner::NonOwner(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
MaybeOwner::Phantom => {}
}
}
}
};HashStable_Generic)]
1650pub enum MaybeOwner<'tcx> {
1651 Owner(&'tcx OwnerInfo<'tcx>),
1652 NonOwner(HirId),
1653 Phantom,
1655}
1656
1657impl<'tcx> MaybeOwner<'tcx> {
1658 pub fn as_owner(self) -> Option<&'tcx OwnerInfo<'tcx>> {
1659 match self {
1660 MaybeOwner::Owner(i) => Some(i),
1661 MaybeOwner::NonOwner(_) | MaybeOwner::Phantom => None,
1662 }
1663 }
1664
1665 pub fn unwrap(self) -> &'tcx OwnerInfo<'tcx> {
1666 self.as_owner().unwrap_or_else(|| { ::core::panicking::panic_fmt(format_args!("Not a HIR owner")); }panic!("Not a HIR owner"))
1667 }
1668}
1669
1670#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Crate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Crate",
"owners", &self.owners, "opt_hir_hash", &&self.opt_hir_hash)
}
}Debug)]
1677pub struct Crate<'hir> {
1678 pub owners: IndexVec<LocalDefId, MaybeOwner<'hir>>,
1679 pub opt_hir_hash: Option<Fingerprint>,
1681}
1682
1683#[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"];
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];
::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>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Closure<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Closure<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
{ __binding_7.hash_stable(__hcx, __hasher); }
{ __binding_8.hash_stable(__hcx, __hasher); }
{ __binding_9.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1684pub struct Closure<'hir> {
1685 pub def_id: LocalDefId,
1686 pub binder: ClosureBinder,
1687 pub constness: Constness,
1688 pub capture_clause: CaptureBy,
1689 pub bound_generic_params: &'hir [GenericParam<'hir>],
1690 pub fn_decl: &'hir FnDecl<'hir>,
1691 pub body: BodyId,
1692 pub fn_decl_span: Span,
1694 pub fn_arg_span: Option<Span>,
1696 pub kind: ClosureKind,
1697}
1698
1699#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ClosureKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ClosureKind::Closure => {}
ClosureKind::Coroutine(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ClosureKind::CoroutineClosure(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, 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)]
1700pub enum ClosureKind {
1701 Closure,
1703 Coroutine(CoroutineKind),
1708 CoroutineClosure(CoroutineDesugaring),
1713}
1714
1715#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Block<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{}
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1719pub struct Block<'hir> {
1720 pub stmts: &'hir [Stmt<'hir>],
1722 pub expr: Option<&'hir Expr<'hir>>,
1725 #[stable_hasher(ignore)]
1726 pub hir_id: HirId,
1727 pub rules: BlockCheckMode,
1729 pub span: Span,
1731 pub targeted_by_break: bool,
1735}
1736
1737impl<'hir> Block<'hir> {
1738 pub fn innermost_block(&self) -> &Block<'hir> {
1739 let mut block = self;
1740 while let Some(Expr { kind: ExprKind::Block(inner_block, _), .. }) = block.expr {
1741 block = inner_block;
1742 }
1743 block
1744 }
1745}
1746
1747#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for TyFieldPath where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TyFieldPath {
variant: ref __binding_0, field: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1748pub struct TyFieldPath {
1749 pub variant: Option<Ident>,
1750 pub field: Ident,
1751}
1752
1753#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TyPat<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TyPat {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1754pub struct TyPat<'hir> {
1755 #[stable_hasher(ignore)]
1756 pub hir_id: HirId,
1757 pub kind: TyPatKind<'hir>,
1758 pub span: Span,
1759}
1760
1761#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Pat<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1762pub struct Pat<'hir> {
1763 #[stable_hasher(ignore)]
1764 pub hir_id: HirId,
1765 pub kind: PatKind<'hir>,
1766 pub span: Span,
1767 pub default_binding_modes: bool,
1770}
1771
1772impl<'hir> Pat<'hir> {
1773 fn walk_short_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) -> bool {
1774 if !it(self) {
1775 return false;
1776 }
1777
1778 use PatKind::*;
1779 match self.kind {
1780 Missing => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1781 Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => true,
1782 Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => {
1783 s.walk_short_(it)
1784 }
1785 Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
1786 TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().all(|p| p.walk_short_(it)),
1787 Slice(before, slice, after) => {
1788 before.iter().chain(slice).chain(after.iter()).all(|p| p.walk_short_(it))
1789 }
1790 }
1791 }
1792
1793 pub fn walk_short(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) -> bool {
1800 self.walk_short_(&mut it)
1801 }
1802
1803 fn walk_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) {
1804 if !it(self) {
1805 return;
1806 }
1807
1808 use PatKind::*;
1809 match self.kind {
1810 Missing | Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => {}
1811 Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_(it),
1812 Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
1813 TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
1814 Slice(before, slice, after) => {
1815 before.iter().chain(slice).chain(after.iter()).for_each(|p| p.walk_(it))
1816 }
1817 }
1818 }
1819
1820 pub fn walk(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) {
1824 self.walk_(&mut it)
1825 }
1826
1827 pub fn walk_always(&self, mut it: impl FnMut(&Pat<'_>)) {
1831 self.walk(|p| {
1832 it(p);
1833 true
1834 })
1835 }
1836
1837 pub fn is_never_pattern(&self) -> bool {
1839 let mut is_never_pattern = false;
1840 self.walk(|pat| match &pat.kind {
1841 PatKind::Never => {
1842 is_never_pattern = true;
1843 false
1844 }
1845 PatKind::Or(s) => {
1846 is_never_pattern = s.iter().all(|p| p.is_never_pattern());
1847 false
1848 }
1849 _ => true,
1850 });
1851 is_never_pattern
1852 }
1853
1854 pub fn is_guaranteed_to_constitute_read_for_never(&self) -> bool {
1863 match self.kind {
1864 PatKind::Wild => false,
1866
1867 PatKind::Guard(pat, _) => pat.is_guaranteed_to_constitute_read_for_never(),
1870
1871 PatKind::Or(subpats) => {
1880 subpats.iter().all(|pat| pat.is_guaranteed_to_constitute_read_for_never())
1881 }
1882
1883 PatKind::Never => true,
1885
1886 PatKind::Missing
1889 | PatKind::Binding(_, _, _, _)
1890 | PatKind::Struct(_, _, _)
1891 | PatKind::TupleStruct(_, _, _)
1892 | PatKind::Tuple(_, _)
1893 | PatKind::Box(_)
1894 | PatKind::Ref(_, _, _)
1895 | PatKind::Deref(_)
1896 | PatKind::Expr(_)
1897 | PatKind::Range(_, _, _)
1898 | PatKind::Slice(_, _, _)
1899 | PatKind::Err(_) => true,
1900 }
1901 }
1902}
1903
1904#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PatField<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1910pub struct PatField<'hir> {
1911 #[stable_hasher(ignore)]
1912 pub hir_id: HirId,
1913 pub ident: Ident,
1915 pub pat: &'hir Pat<'hir>,
1917 pub is_shorthand: bool,
1918 pub span: Span,
1919}
1920
1921#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for RangeEnd where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
RangeEnd::Included => {}
RangeEnd::Excluded => {}
}
}
}
};HashStable_Generic, #[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)]
1922pub enum RangeEnd {
1923 Included,
1924 Excluded,
1925}
1926
1927impl fmt::Display for RangeEnd {
1928 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1929 f.write_str(match self {
1930 RangeEnd::Included => "..=",
1931 RangeEnd::Excluded => "..",
1932 })
1933 }
1934}
1935
1936#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for DotDotPos where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
DotDotPos(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1940pub struct DotDotPos(u32);
1941
1942impl DotDotPos {
1943 pub fn new(n: Option<usize>) -> Self {
1945 match n {
1946 Some(n) => {
1947 if !(n < u32::MAX as usize) {
::core::panicking::panic("assertion failed: n < u32::MAX as usize")
};assert!(n < u32::MAX as usize);
1948 Self(n as u32)
1949 }
1950 None => Self(u32::MAX),
1951 }
1952 }
1953
1954 pub fn as_opt_usize(&self) -> Option<usize> {
1955 if self.0 == u32::MAX { None } else { Some(self.0 as usize) }
1956 }
1957}
1958
1959impl fmt::Debug for DotDotPos {
1960 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1961 self.as_opt_usize().fmt(f)
1962 }
1963}
1964
1965#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PatExpr<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
PatExpr {
hir_id: ref __binding_0,
span: ref __binding_1,
kind: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1966pub struct PatExpr<'hir> {
1967 #[stable_hasher(ignore)]
1968 pub hir_id: HirId,
1969 pub span: Span,
1970 pub kind: PatExprKind<'hir>,
1971}
1972
1973#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PatExprKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
PatExprKind::Lit {
lit: ref __binding_0, negated: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
PatExprKind::Path(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1974pub enum PatExprKind<'hir> {
1975 Lit {
1976 lit: Lit,
1977 negated: bool,
1978 },
1979 Path(QPath<'hir>),
1981}
1982
1983#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TyPatKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
TyPatKind::Range(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyPatKind::NotNull => {}
TyPatKind::Or(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyPatKind::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1984pub enum TyPatKind<'hir> {
1985 Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>),
1987
1988 NotNull,
1990
1991 Or(&'hir [TyPat<'hir>]),
1993
1994 Err(ErrorGuaranteed),
1996}
1997
1998#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PatKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
PatKind::Missing => {}
PatKind::Wild => {}
PatKind::Binding(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
PatKind::Struct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
PatKind::TupleStruct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
PatKind::Or(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PatKind::Never => {}
PatKind::Tuple(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
PatKind::Box(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PatKind::Deref(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PatKind::Ref(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
PatKind::Expr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PatKind::Guard(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
PatKind::Range(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
PatKind::Slice(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
PatKind::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1999pub enum PatKind<'hir> {
2000 Missing,
2002
2003 Wild,
2005
2006 Binding(BindingMode, HirId, Ident, Option<&'hir Pat<'hir>>),
2017
2018 Struct(QPath<'hir>, &'hir [PatField<'hir>], Option<Span>),
2021
2022 TupleStruct(QPath<'hir>, &'hir [Pat<'hir>], DotDotPos),
2026
2027 Or(&'hir [Pat<'hir>]),
2030
2031 Never,
2033
2034 Tuple(&'hir [Pat<'hir>], DotDotPos),
2038
2039 Box(&'hir Pat<'hir>),
2041
2042 Deref(&'hir Pat<'hir>),
2044
2045 Ref(&'hir Pat<'hir>, Pinnedness, Mutability),
2047
2048 Expr(&'hir PatExpr<'hir>),
2050
2051 Guard(&'hir Pat<'hir>, &'hir Expr<'hir>),
2053
2054 Range(Option<&'hir PatExpr<'hir>>, Option<&'hir PatExpr<'hir>>, RangeEnd),
2056
2057 Slice(&'hir [Pat<'hir>], Option<&'hir Pat<'hir>>, &'hir [Pat<'hir>]),
2067
2068 Err(ErrorGuaranteed),
2070}
2071
2072#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Stmt<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Stmt {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2074pub struct Stmt<'hir> {
2075 #[stable_hasher(ignore)]
2076 pub hir_id: HirId,
2077 pub kind: StmtKind<'hir>,
2078 pub span: Span,
2079}
2080
2081#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
StmtKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
StmtKind::Let(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
StmtKind::Item(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
StmtKind::Expr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
StmtKind::Semi(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2083pub enum StmtKind<'hir> {
2084 Let(&'hir LetStmt<'hir>),
2086
2087 Item(ItemId),
2089
2090 Expr(&'hir Expr<'hir>),
2092
2093 Semi(&'hir Expr<'hir>),
2095}
2096
2097#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
LetStmt<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{}
{ __binding_6.hash_stable(__hcx, __hasher); }
{ __binding_7.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2099pub struct LetStmt<'hir> {
2100 pub super_: Option<Span>,
2102 pub pat: &'hir Pat<'hir>,
2103 pub ty: Option<&'hir Ty<'hir>>,
2105 pub init: Option<&'hir Expr<'hir>>,
2107 pub els: Option<&'hir Block<'hir>>,
2109 #[stable_hasher(ignore)]
2110 pub hir_id: HirId,
2111 pub span: Span,
2112 pub source: LocalSource,
2116}
2117
2118#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Arm<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2121pub struct Arm<'hir> {
2122 #[stable_hasher(ignore)]
2123 pub hir_id: HirId,
2124 pub span: Span,
2125 pub pat: &'hir Pat<'hir>,
2127 pub guard: Option<&'hir Expr<'hir>>,
2129 pub body: &'hir Expr<'hir>,
2131}
2132
2133#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
LetExpr<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2139pub struct LetExpr<'hir> {
2140 pub span: Span,
2141 pub pat: &'hir Pat<'hir>,
2142 pub ty: Option<&'hir Ty<'hir>>,
2143 pub init: &'hir Expr<'hir>,
2144 pub recovered: ast::Recovered,
2147}
2148
2149#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ExprField<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2150pub struct ExprField<'hir> {
2151 #[stable_hasher(ignore)]
2152 pub hir_id: HirId,
2153 pub ident: Ident,
2154 pub expr: &'hir Expr<'hir>,
2155 pub span: Span,
2156 pub is_shorthand: bool,
2157}
2158
2159#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for BlockCheckMode where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
BlockCheckMode::DefaultBlock => {}
BlockCheckMode::UnsafeBlock(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2160pub enum BlockCheckMode {
2161 DefaultBlock,
2162 UnsafeBlock(UnsafeSource),
2163}
2164
2165#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for UnsafeSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
UnsafeSource::CompilerGenerated => {}
UnsafeSource::UserProvided => {}
}
}
}
};HashStable_Generic)]
2166pub enum UnsafeSource {
2167 CompilerGenerated,
2168 UserProvided,
2169}
2170
2171#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for BodyId where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
BodyId { hir_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2172pub struct BodyId {
2173 pub hir_id: HirId,
2174}
2175
2176#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Body<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Body { params: ref __binding_0, value: ref __binding_1 } =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2198pub struct Body<'hir> {
2199 pub params: &'hir [Param<'hir>],
2200 pub value: &'hir Expr<'hir>,
2201}
2202
2203impl<'hir> Body<'hir> {
2204 pub fn id(&self) -> BodyId {
2205 BodyId { hir_id: self.value.hir_id }
2206 }
2207}
2208
2209#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for CoroutineKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
CoroutineKind::Desugared(ref __binding_0, ref __binding_1)
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
CoroutineKind::Coroutine(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, 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)]
2211pub enum CoroutineKind {
2212 Desugared(CoroutineDesugaring, CoroutineSource),
2214
2215 Coroutine(Movability),
2217}
2218
2219impl CoroutineKind {
2220 pub fn movability(self) -> Movability {
2221 match self {
2222 CoroutineKind::Desugared(CoroutineDesugaring::Async, _)
2223 | CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _) => Movability::Static,
2224 CoroutineKind::Desugared(CoroutineDesugaring::Gen, _) => Movability::Movable,
2225 CoroutineKind::Coroutine(mov) => mov,
2226 }
2227 }
2228
2229 pub fn is_fn_like(self) -> bool {
2230 #[allow(non_exhaustive_omitted_patterns)] match self {
CoroutineKind::Desugared(_, CoroutineSource::Fn) => true,
_ => false,
}matches!(self, CoroutineKind::Desugared(_, CoroutineSource::Fn))
2231 }
2232
2233 pub fn to_plural_string(&self) -> String {
2234 match self {
2235 CoroutineKind::Desugared(d, CoroutineSource::Fn) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}fn bodies", d))
})format!("{d:#}fn bodies"),
2236 CoroutineKind::Desugared(d, CoroutineSource::Block) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}blocks", d))
})format!("{d:#}blocks"),
2237 CoroutineKind::Desugared(d, CoroutineSource::Closure) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}closure bodies", d))
})format!("{d:#}closure bodies"),
2238 CoroutineKind::Coroutine(_) => "coroutines".to_string(),
2239 }
2240 }
2241}
2242
2243impl fmt::Display for CoroutineKind {
2244 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2245 match self {
2246 CoroutineKind::Desugared(d, k) => {
2247 d.fmt(f)?;
2248 k.fmt(f)
2249 }
2250 CoroutineKind::Coroutine(_) => f.write_str("coroutine"),
2251 }
2252 }
2253}
2254
2255#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for CoroutineSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
CoroutineSource::Block => {}
CoroutineSource::Closure => {}
CoroutineSource::Fn => {}
}
}
}
};HashStable_Generic, 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)]
2261pub enum CoroutineSource {
2262 Block,
2264
2265 Closure,
2267
2268 Fn,
2270}
2271
2272impl fmt::Display for CoroutineSource {
2273 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2274 match self {
2275 CoroutineSource::Block => "block",
2276 CoroutineSource::Closure => "closure body",
2277 CoroutineSource::Fn => "fn body",
2278 }
2279 .fmt(f)
2280 }
2281}
2282
2283#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for CoroutineDesugaring where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
CoroutineDesugaring::Async => {}
CoroutineDesugaring::Gen => {}
CoroutineDesugaring::AsyncGen => {}
}
}
}
};HashStable_Generic, 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)]
2284pub enum CoroutineDesugaring {
2285 Async,
2287
2288 Gen,
2290
2291 AsyncGen,
2294}
2295
2296impl fmt::Display for CoroutineDesugaring {
2297 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2298 match self {
2299 CoroutineDesugaring::Async => {
2300 if f.alternate() {
2301 f.write_str("`async` ")?;
2302 } else {
2303 f.write_str("async ")?
2304 }
2305 }
2306 CoroutineDesugaring::Gen => {
2307 if f.alternate() {
2308 f.write_str("`gen` ")?;
2309 } else {
2310 f.write_str("gen ")?
2311 }
2312 }
2313 CoroutineDesugaring::AsyncGen => {
2314 if f.alternate() {
2315 f.write_str("`async gen` ")?;
2316 } else {
2317 f.write_str("async gen ")?
2318 }
2319 }
2320 }
2321
2322 Ok(())
2323 }
2324}
2325
2326#[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)]
2327pub enum BodyOwnerKind {
2328 Fn,
2330
2331 Closure,
2333
2334 Const { inline: bool },
2336
2337 Static(Mutability),
2339
2340 GlobalAsm,
2342}
2343
2344impl BodyOwnerKind {
2345 pub fn is_fn_or_closure(self) -> bool {
2346 match self {
2347 BodyOwnerKind::Fn | BodyOwnerKind::Closure => true,
2348 BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(_) | BodyOwnerKind::GlobalAsm => {
2349 false
2350 }
2351 }
2352 }
2353}
2354
2355#[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 { inline: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Const",
"inline", &__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 { inline: __self_0 },
ConstContext::Const { inline: __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)]
2357pub enum ConstContext {
2358 ConstFn,
2360
2361 Static(Mutability),
2363
2364 Const { inline: bool },
2374}
2375
2376impl ConstContext {
2377 pub fn keyword_name(self) -> &'static str {
2381 match self {
2382 Self::Const { .. } => "const",
2383 Self::Static(Mutability::Not) => "static",
2384 Self::Static(Mutability::Mut) => "static mut",
2385 Self::ConstFn => "const fn",
2386 }
2387 }
2388}
2389
2390impl fmt::Display for ConstContext {
2393 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2394 match *self {
2395 Self::Const { .. } => f.write_fmt(format_args!("constant"))write!(f, "constant"),
2396 Self::Static(_) => f.write_fmt(format_args!("static"))write!(f, "static"),
2397 Self::ConstFn => f.write_fmt(format_args!("constant function"))write!(f, "constant function"),
2398 }
2399 }
2400}
2401
2402impl IntoDiagArg for ConstContext {
2403 fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
2404 DiagArgValue::Str(Cow::Borrowed(match self {
2405 ConstContext::ConstFn => "const_fn",
2406 ConstContext::Static(_) => "static",
2407 ConstContext::Const { .. } => "const",
2408 }))
2409 }
2410}
2411
2412pub type Lit = Spanned<LitKind>;
2414
2415#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AnonConst where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
AnonConst {
hir_id: ref __binding_0,
def_id: ref __binding_1,
body: ref __binding_2,
span: ref __binding_3 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2424pub struct AnonConst {
2425 #[stable_hasher(ignore)]
2426 pub hir_id: HirId,
2427 pub def_id: LocalDefId,
2428 pub body: BodyId,
2429 pub span: Span,
2430}
2431
2432#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ConstBlock where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ConstBlock {
hir_id: ref __binding_0,
def_id: ref __binding_1,
body: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2434pub struct ConstBlock {
2435 #[stable_hasher(ignore)]
2436 pub hir_id: HirId,
2437 pub def_id: LocalDefId,
2438 pub body: BodyId,
2439}
2440
2441#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Expr<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Expr {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2450pub struct Expr<'hir> {
2451 #[stable_hasher(ignore)]
2452 pub hir_id: HirId,
2453 pub kind: ExprKind<'hir>,
2454 pub span: Span,
2455}
2456
2457impl Expr<'_> {
2458 pub fn precedence(&self, has_attr: &dyn Fn(HirId) -> bool) -> ExprPrecedence {
2459 let prefix_attrs_precedence = || -> ExprPrecedence {
2460 if has_attr(self.hir_id) { ExprPrecedence::Prefix } else { ExprPrecedence::Unambiguous }
2461 };
2462
2463 match &self.kind {
2464 ExprKind::Closure(closure) => {
2465 match closure.fn_decl.output {
2466 FnRetTy::DefaultReturn(_) => ExprPrecedence::Jump,
2467 FnRetTy::Return(_) => prefix_attrs_precedence(),
2468 }
2469 }
2470
2471 ExprKind::Break(..)
2472 | ExprKind::Ret(..)
2473 | ExprKind::Yield(..)
2474 | ExprKind::Become(..) => ExprPrecedence::Jump,
2475
2476 ExprKind::Binary(op, ..) => op.node.precedence(),
2478 ExprKind::Cast(..) => ExprPrecedence::Cast,
2479
2480 ExprKind::Assign(..) |
2481 ExprKind::AssignOp(..) => ExprPrecedence::Assign,
2482
2483 ExprKind::AddrOf(..)
2485 | ExprKind::Let(..)
2490 | ExprKind::Unary(..) => ExprPrecedence::Prefix,
2491
2492 ExprKind::Array(_)
2494 | ExprKind::Block(..)
2495 | ExprKind::Call(..)
2496 | ExprKind::ConstBlock(_)
2497 | ExprKind::Continue(..)
2498 | ExprKind::Field(..)
2499 | ExprKind::If(..)
2500 | ExprKind::Index(..)
2501 | ExprKind::InlineAsm(..)
2502 | ExprKind::Lit(_)
2503 | ExprKind::Loop(..)
2504 | ExprKind::Match(..)
2505 | ExprKind::MethodCall(..)
2506 | ExprKind::OffsetOf(..)
2507 | ExprKind::Path(..)
2508 | ExprKind::Repeat(..)
2509 | ExprKind::Struct(..)
2510 | ExprKind::Tup(_)
2511 | ExprKind::Type(..)
2512 | ExprKind::UnsafeBinderCast(..)
2513 | ExprKind::Use(..)
2514 | ExprKind::Err(_) => prefix_attrs_precedence(),
2515
2516 ExprKind::DropTemps(expr, ..) => expr.precedence(has_attr),
2517 }
2518 }
2519
2520 pub fn is_syntactic_place_expr(&self) -> bool {
2525 self.is_place_expr(|_| true)
2526 }
2527
2528 pub fn is_place_expr(&self, mut allow_projections_from: impl FnMut(&Self) -> bool) -> bool {
2533 match self.kind {
2534 ExprKind::Path(QPath::Resolved(_, ref path)) => {
2535 #[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)
2536 }
2537
2538 ExprKind::Type(ref e, _) => e.is_place_expr(allow_projections_from),
2542
2543 ExprKind::UnsafeBinderCast(_, e, _) => e.is_place_expr(allow_projections_from),
2545
2546 ExprKind::Unary(UnOp::Deref, _) => true,
2547
2548 ExprKind::Field(ref base, _) | ExprKind::Index(ref base, _, _) => {
2549 allow_projections_from(base) || base.is_place_expr(allow_projections_from)
2550 }
2551
2552 ExprKind::Err(_guar)
2554 | ExprKind::Let(&LetExpr { recovered: ast::Recovered::Yes(_guar), .. }) => true,
2555
2556 ExprKind::Path(QPath::TypeRelative(..))
2559 | ExprKind::Call(..)
2560 | ExprKind::MethodCall(..)
2561 | ExprKind::Use(..)
2562 | ExprKind::Struct(..)
2563 | ExprKind::Tup(..)
2564 | ExprKind::If(..)
2565 | ExprKind::Match(..)
2566 | ExprKind::Closure { .. }
2567 | ExprKind::Block(..)
2568 | ExprKind::Repeat(..)
2569 | ExprKind::Array(..)
2570 | ExprKind::Break(..)
2571 | ExprKind::Continue(..)
2572 | ExprKind::Ret(..)
2573 | ExprKind::Become(..)
2574 | ExprKind::Let(..)
2575 | ExprKind::Loop(..)
2576 | ExprKind::Assign(..)
2577 | ExprKind::InlineAsm(..)
2578 | ExprKind::OffsetOf(..)
2579 | ExprKind::AssignOp(..)
2580 | ExprKind::Lit(_)
2581 | ExprKind::ConstBlock(..)
2582 | ExprKind::Unary(..)
2583 | ExprKind::AddrOf(..)
2584 | ExprKind::Binary(..)
2585 | ExprKind::Yield(..)
2586 | ExprKind::Cast(..)
2587 | ExprKind::DropTemps(..) => false,
2588 }
2589 }
2590
2591 pub fn range_span(&self) -> Option<Span> {
2594 is_range_literal(self).then(|| self.span.parent_callsite().unwrap())
2595 }
2596
2597 pub fn is_size_lit(&self) -> bool {
2600 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ExprKind::Lit(Lit {
node: LitKind::Int(_,
LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)), ..
}) => true,
_ => false,
}matches!(
2601 self.kind,
2602 ExprKind::Lit(Lit {
2603 node: LitKind::Int(_, LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)),
2604 ..
2605 })
2606 )
2607 }
2608
2609 pub fn peel_drop_temps(&self) -> &Self {
2615 let mut expr = self;
2616 while let ExprKind::DropTemps(inner) = &expr.kind {
2617 expr = inner;
2618 }
2619 expr
2620 }
2621
2622 pub fn peel_blocks(&self) -> &Self {
2623 let mut expr = self;
2624 while let ExprKind::Block(Block { expr: Some(inner), .. }, _) = &expr.kind {
2625 expr = inner;
2626 }
2627 expr
2628 }
2629
2630 pub fn peel_borrows(&self) -> &Self {
2631 let mut expr = self;
2632 while let ExprKind::AddrOf(.., inner) = &expr.kind {
2633 expr = inner;
2634 }
2635 expr
2636 }
2637
2638 pub fn can_have_side_effects(&self) -> bool {
2639 match self.peel_drop_temps().kind {
2640 ExprKind::Path(_) | ExprKind::Lit(_) | ExprKind::OffsetOf(..) | ExprKind::Use(..) => {
2641 false
2642 }
2643 ExprKind::Type(base, _)
2644 | ExprKind::Unary(_, base)
2645 | ExprKind::Field(base, _)
2646 | ExprKind::Index(base, _, _)
2647 | ExprKind::AddrOf(.., base)
2648 | ExprKind::Cast(base, _)
2649 | ExprKind::UnsafeBinderCast(_, base, _) => {
2650 base.can_have_side_effects()
2654 }
2655 ExprKind::Binary(_, lhs, rhs) => {
2656 lhs.can_have_side_effects() || rhs.can_have_side_effects()
2660 }
2661 ExprKind::Struct(_, fields, init) => {
2662 let init_side_effects = match init {
2663 StructTailExpr::Base(init) => init.can_have_side_effects(),
2664 StructTailExpr::DefaultFields(_)
2665 | StructTailExpr::None
2666 | StructTailExpr::NoneWithError(_) => false,
2667 };
2668 fields.iter().map(|field| field.expr).any(|e| e.can_have_side_effects())
2669 || init_side_effects
2670 }
2671
2672 ExprKind::Array(args)
2673 | ExprKind::Tup(args)
2674 | ExprKind::Call(
2675 Expr {
2676 kind:
2677 ExprKind::Path(QPath::Resolved(
2678 None,
2679 Path { res: Res::Def(DefKind::Ctor(_, CtorKind::Fn), _), .. },
2680 )),
2681 ..
2682 },
2683 args,
2684 ) => args.iter().any(|arg| arg.can_have_side_effects()),
2685 ExprKind::Repeat(arg, _) => arg.can_have_side_effects(),
2686 ExprKind::If(..)
2687 | ExprKind::Match(..)
2688 | ExprKind::MethodCall(..)
2689 | ExprKind::Call(..)
2690 | ExprKind::Closure { .. }
2691 | ExprKind::Block(..)
2692 | ExprKind::Break(..)
2693 | ExprKind::Continue(..)
2694 | ExprKind::Ret(..)
2695 | ExprKind::Become(..)
2696 | ExprKind::Let(..)
2697 | ExprKind::Loop(..)
2698 | ExprKind::Assign(..)
2699 | ExprKind::InlineAsm(..)
2700 | ExprKind::AssignOp(..)
2701 | ExprKind::ConstBlock(..)
2702 | ExprKind::Yield(..)
2703 | ExprKind::DropTemps(..)
2704 | ExprKind::Err(_) => true,
2705 }
2706 }
2707
2708 pub fn is_approximately_pattern(&self) -> bool {
2710 match &self.kind {
2711 ExprKind::Array(_)
2712 | ExprKind::Call(..)
2713 | ExprKind::Tup(_)
2714 | ExprKind::Lit(_)
2715 | ExprKind::Path(_)
2716 | ExprKind::Struct(..) => true,
2717 _ => false,
2718 }
2719 }
2720
2721 pub fn equivalent_for_indexing(&self, other: &Expr<'_>) -> bool {
2726 match (self.kind, other.kind) {
2727 (ExprKind::Lit(lit1), ExprKind::Lit(lit2)) => lit1.node == lit2.node,
2728 (
2729 ExprKind::Path(QPath::Resolved(None, path1)),
2730 ExprKind::Path(QPath::Resolved(None, path2)),
2731 ) => path1.res == path2.res,
2732 (
2733 ExprKind::Struct(
2734 &QPath::Resolved(None, &Path { res: Res::Def(_, path1_def_id), .. }),
2735 args1,
2736 StructTailExpr::None,
2737 ),
2738 ExprKind::Struct(
2739 &QPath::Resolved(None, &Path { res: Res::Def(_, path2_def_id), .. }),
2740 args2,
2741 StructTailExpr::None,
2742 ),
2743 ) => {
2744 path2_def_id == path1_def_id
2745 && is_range_literal(self)
2746 && is_range_literal(other)
2747 && std::iter::zip(args1, args2)
2748 .all(|(a, b)| a.expr.equivalent_for_indexing(b.expr))
2749 }
2750 _ => false,
2751 }
2752 }
2753
2754 pub fn method_ident(&self) -> Option<Ident> {
2755 match self.kind {
2756 ExprKind::MethodCall(receiver_method, ..) => Some(receiver_method.ident),
2757 ExprKind::Unary(_, expr) | ExprKind::AddrOf(.., expr) => expr.method_ident(),
2758 _ => None,
2759 }
2760 }
2761}
2762
2763pub fn is_range_literal(expr: &Expr<'_>) -> bool {
2766 if let ExprKind::Struct(QPath::Resolved(None, path), _, StructTailExpr::None) = expr.kind
2767 && let [.., segment] = path.segments
2768 && let sym::RangeFrom
2769 | sym::RangeFull
2770 | sym::Range
2771 | sym::RangeToInclusive
2772 | sym::RangeTo
2773 | sym::RangeFromCopy
2774 | sym::RangeCopy
2775 | sym::RangeInclusiveCopy
2776 | sym::RangeToInclusiveCopy = segment.ident.name
2777 && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2778 {
2779 true
2780 } else if let ExprKind::Call(func, _) = &expr.kind
2781 && let ExprKind::Path(QPath::Resolved(None, path)) = func.kind
2782 && let [.., segment] = path.segments
2783 && let sym::range_inclusive_new = segment.ident.name
2784 && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2785 {
2786 true
2787 } else {
2788 false
2789 }
2790}
2791
2792pub fn expr_needs_parens(expr: &Expr<'_>) -> bool {
2799 match expr.kind {
2800 ExprKind::Cast(_, _) | ExprKind::Binary(_, _, _) => true,
2802 _ if is_range_literal(expr) => true,
2804 _ => false,
2805 }
2806}
2807
2808#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ExprKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ExprKind::ConstBlock(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Array(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Call(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::MethodCall(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
ExprKind::Use(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Tup(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Binary(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Unary(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Lit(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Cast(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Type(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::DropTemps(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Let(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::If(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Loop(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
ExprKind::Match(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Closure(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Block(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Assign(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::AssignOp(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Field(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Index(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Path(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::AddrOf(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Break(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Continue(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Ret(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Become(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::InlineAsm(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::OffsetOf(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Struct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Repeat(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Yield(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::UnsafeBinderCast(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2809pub enum ExprKind<'hir> {
2810 ConstBlock(ConstBlock),
2812 Array(&'hir [Expr<'hir>]),
2814 Call(&'hir Expr<'hir>, &'hir [Expr<'hir>]),
2821 MethodCall(&'hir PathSegment<'hir>, &'hir Expr<'hir>, &'hir [Expr<'hir>], Span),
2838 Use(&'hir Expr<'hir>, Span),
2840 Tup(&'hir [Expr<'hir>]),
2842 Binary(BinOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2844 Unary(UnOp, &'hir Expr<'hir>),
2846 Lit(Lit),
2848 Cast(&'hir Expr<'hir>, &'hir Ty<'hir>),
2850 Type(&'hir Expr<'hir>, &'hir Ty<'hir>),
2852 DropTemps(&'hir Expr<'hir>),
2858 Let(&'hir LetExpr<'hir>),
2863 If(&'hir Expr<'hir>, &'hir Expr<'hir>, Option<&'hir Expr<'hir>>),
2872 Loop(&'hir Block<'hir>, Option<Label>, LoopSource, Span),
2878 Match(&'hir Expr<'hir>, &'hir [Arm<'hir>], MatchSource),
2881 Closure(&'hir Closure<'hir>),
2888 Block(&'hir Block<'hir>, Option<Label>),
2890
2891 Assign(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
2893 AssignOp(AssignOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2897 Field(&'hir Expr<'hir>, Ident),
2899 Index(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
2903
2904 Path(QPath<'hir>),
2906
2907 AddrOf(BorrowKind, Mutability, &'hir Expr<'hir>),
2909 Break(Destination, Option<&'hir Expr<'hir>>),
2911 Continue(Destination),
2913 Ret(Option<&'hir Expr<'hir>>),
2915 Become(&'hir Expr<'hir>),
2917
2918 InlineAsm(&'hir InlineAsm<'hir>),
2920
2921 OffsetOf(&'hir Ty<'hir>, &'hir [Ident]),
2923
2924 Struct(&'hir QPath<'hir>, &'hir [ExprField<'hir>], StructTailExpr<'hir>),
2929
2930 Repeat(&'hir Expr<'hir>, &'hir ConstArg<'hir>),
2935
2936 Yield(&'hir Expr<'hir>, YieldSource),
2938
2939 UnsafeBinderCast(UnsafeBinderCastKind, &'hir Expr<'hir>, Option<&'hir Ty<'hir>>),
2942
2943 Err(rustc_span::ErrorGuaranteed),
2945}
2946
2947#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
StructTailExpr<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
StructTailExpr::None => {}
StructTailExpr::Base(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
StructTailExpr::DefaultFields(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
StructTailExpr::NoneWithError(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2948pub enum StructTailExpr<'hir> {
2949 None,
2951 Base(&'hir Expr<'hir>),
2954 DefaultFields(Span),
2958 NoneWithError(ErrorGuaranteed),
2964}
2965
2966#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
QPath<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
QPath::Resolved(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
QPath::TypeRelative(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2972pub enum QPath<'hir> {
2973 Resolved(Option<&'hir Ty<'hir>>, &'hir Path<'hir>),
2980
2981 TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
2988}
2989
2990impl<'hir> QPath<'hir> {
2991 pub fn span(&self) -> Span {
2993 match *self {
2994 QPath::Resolved(_, path) => path.span,
2995 QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
2996 }
2997 }
2998
2999 pub fn qself_span(&self) -> Span {
3002 match *self {
3003 QPath::Resolved(_, path) => path.span,
3004 QPath::TypeRelative(qself, _) => qself.span,
3005 }
3006 }
3007}
3008
3009#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LocalSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LocalSource::Normal => {}
LocalSource::AsyncFn => {}
LocalSource::AwaitDesugar => {}
LocalSource::AssignDesugar => {}
LocalSource::Contract => {}
}
}
}
};HashStable_Generic)]
3011pub enum LocalSource {
3012 Normal,
3014 AsyncFn,
3025 AwaitDesugar,
3027 AssignDesugar,
3029 Contract,
3031}
3032
3033#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for MatchSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
MatchSource::Normal => {}
MatchSource::Postfix => {}
MatchSource::ForLoopDesugar => {}
MatchSource::TryDesugar(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
MatchSource::AwaitDesugar => {}
MatchSource::FormatArgs => {}
}
}
}
};HashStable_Generic, 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)]
3035pub enum MatchSource {
3036 Normal,
3038 Postfix,
3040 ForLoopDesugar,
3042 TryDesugar(HirId),
3044 AwaitDesugar,
3046 FormatArgs,
3048}
3049
3050impl MatchSource {
3051 #[inline]
3052 pub const fn name(self) -> &'static str {
3053 use MatchSource::*;
3054 match self {
3055 Normal => "match",
3056 Postfix => ".match",
3057 ForLoopDesugar => "for",
3058 TryDesugar(_) => "?",
3059 AwaitDesugar => ".await",
3060 FormatArgs => "format_args!()",
3061 }
3062 }
3063}
3064
3065#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LoopSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LoopSource::Loop => {}
LoopSource::While => {}
LoopSource::ForLoop => {}
}
}
}
};HashStable_Generic)]
3067pub enum LoopSource {
3068 Loop,
3070 While,
3072 ForLoop,
3074}
3075
3076impl LoopSource {
3077 pub fn name(self) -> &'static str {
3078 match self {
3079 LoopSource::Loop => "loop",
3080 LoopSource::While => "while",
3081 LoopSource::ForLoop => "for",
3082 }
3083 }
3084}
3085
3086#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LoopIdError where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LoopIdError::OutsideLoopScope => {}
LoopIdError::UnlabeledCfInWhileCondition => {}
LoopIdError::UnresolvedLabel => {}
}
}
}
};HashStable_Generic)]
3087pub enum LoopIdError {
3088 OutsideLoopScope,
3089 UnlabeledCfInWhileCondition,
3090 UnresolvedLabel,
3091}
3092
3093impl fmt::Display for LoopIdError {
3094 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3095 f.write_str(match self {
3096 LoopIdError::OutsideLoopScope => "not inside loop scope",
3097 LoopIdError::UnlabeledCfInWhileCondition => {
3098 "unlabeled control flow (break or continue) in while condition"
3099 }
3100 LoopIdError::UnresolvedLabel => "label not found",
3101 })
3102 }
3103}
3104
3105#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Destination where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Destination {
label: ref __binding_0, target_id: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3106pub struct Destination {
3107 pub label: Option<Label>,
3109
3110 pub target_id: Result<HirId, LoopIdError>,
3113}
3114
3115#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for YieldSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
YieldSource::Await { expr: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
YieldSource::Yield => {}
}
}
}
};HashStable_Generic)]
3117pub enum YieldSource {
3118 Await { expr: Option<HirId> },
3120 Yield,
3122}
3123
3124impl fmt::Display for YieldSource {
3125 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3126 f.write_str(match self {
3127 YieldSource::Await { .. } => "`await`",
3128 YieldSource::Yield => "`yield`",
3129 })
3130 }
3131}
3132
3133#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
MutTy<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
MutTy { ty: ref __binding_0, mutbl: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3136pub struct MutTy<'hir> {
3137 pub ty: &'hir Ty<'hir>,
3138 pub mutbl: Mutability,
3139}
3140
3141#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnSig<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FnSig {
header: ref __binding_0,
decl: ref __binding_1,
span: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3144pub struct FnSig<'hir> {
3145 pub header: FnHeader,
3146 pub decl: &'hir FnDecl<'hir>,
3147 pub span: Span,
3148}
3149
3150#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for TraitItemId where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitItemId { owner_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3154pub struct TraitItemId {
3155 pub owner_id: OwnerId,
3156}
3157
3158impl TraitItemId {
3159 #[inline]
3160 pub fn hir_id(&self) -> HirId {
3161 HirId::make_owner(self.owner_id.def_id)
3163 }
3164}
3165
3166#[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",
"has_delayed_lints"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.owner_id, &self.generics, &self.kind,
&self.span, &self.defaultness, &&self.has_delayed_lints];
::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>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitItem<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitItem<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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,
has_delayed_lints: ref __binding_6 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3171pub struct TraitItem<'hir> {
3172 pub ident: Ident,
3173 pub owner_id: OwnerId,
3174 pub generics: &'hir Generics<'hir>,
3175 pub kind: TraitItemKind<'hir>,
3176 pub span: Span,
3177 pub defaultness: Defaultness,
3178 pub has_delayed_lints: bool,
3179}
3180
3181macro_rules! expect_methods_self_kind {
3182 ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3183 $(
3184 #[track_caller]
3185 pub fn $name(&self) -> $ret_ty {
3186 let $pat = &self.kind else { expect_failed(stringify!($name), self) };
3187 $ret_val
3188 }
3189 )*
3190 }
3191}
3192
3193macro_rules! expect_methods_self {
3194 ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3195 $(
3196 #[track_caller]
3197 pub fn $name(&self) -> $ret_ty {
3198 let $pat = self else { expect_failed(stringify!($name), self) };
3199 $ret_val
3200 }
3201 )*
3202 }
3203}
3204
3205#[track_caller]
3206fn expect_failed<T: fmt::Debug>(ident: &'static str, found: T) -> ! {
3207 {
::core::panicking::panic_fmt(format_args!("{0}: found {1:?}", ident,
found));
}panic!("{ident}: found {found:?}")
3208}
3209
3210impl<'hir> TraitItem<'hir> {
3211 #[inline]
3212 pub fn hir_id(&self) -> HirId {
3213 HirId::make_owner(self.owner_id.def_id)
3215 }
3216
3217 pub fn trait_item_id(&self) -> TraitItemId {
3218 TraitItemId { owner_id: self.owner_id }
3219 }
3220
3221 self
let TraitItemKind::Type(bounds, ty) =
&self.kind else { expect_failed("expect_type", self) };
(bounds, *ty);expect_methods_self_kind! {
3222 expect_const, (&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>),
3223 TraitItemKind::Const(ty, rhs, _), (ty, *rhs);
3224
3225 expect_fn, (&FnSig<'hir>, &TraitFn<'hir>),
3226 TraitItemKind::Fn(ty, trfn), (ty, trfn);
3227
3228 expect_type, (GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3229 TraitItemKind::Type(bounds, ty), (bounds, *ty);
3230 }
3231}
3232
3233#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitFn<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
TraitFn::Required(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TraitFn::Provided(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3235pub enum TraitFn<'hir> {
3236 Required(&'hir [Option<Ident>]),
3238
3239 Provided(BodyId),
3241}
3242
3243#[derive(#[automatically_derived]
impl ::core::fmt::Debug for IsTypeConst {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
IsTypeConst::No => "No",
IsTypeConst::Yes => "Yes",
})
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for IsTypeConst {
#[inline]
fn clone(&self) -> IsTypeConst { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for IsTypeConst { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for IsTypeConst {
#[inline]
fn eq(&self, other: &IsTypeConst) -> 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 IsTypeConst {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for IsTypeConst where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self { IsTypeConst::No => {} IsTypeConst::Yes => {} }
}
}
};HashStable_Generic)]
3244pub enum IsTypeConst {
3245 No,
3246 Yes,
3247}
3248
3249impl From<bool> for IsTypeConst {
3250 fn from(value: bool) -> Self {
3251 if value { Self::Yes } else { Self::No }
3252 }
3253}
3254
3255impl From<IsTypeConst> for bool {
3256 fn from(value: IsTypeConst) -> Self {
3257 #[allow(non_exhaustive_omitted_patterns)] match value {
IsTypeConst::Yes => true,
_ => false,
}matches!(value, IsTypeConst::Yes)
3258 }
3259}
3260
3261#[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, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Const",
__self_0, __self_1, &__self_2),
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<IsTypeConst>;
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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitItemKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
TraitItemKind::Const(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
TraitItemKind::Fn(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TraitItemKind::Type(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3263pub enum TraitItemKind<'hir> {
3264 Const(&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>, IsTypeConst),
3269 Fn(FnSig<'hir>, TraitFn<'hir>),
3271 Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3274}
3275
3276#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ImplItemId where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ImplItemId { owner_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3280pub struct ImplItemId {
3281 pub owner_id: OwnerId,
3282}
3283
3284impl ImplItemId {
3285 #[inline]
3286 pub fn hir_id(&self) -> HirId {
3287 HirId::make_owner(self.owner_id.def_id)
3289 }
3290}
3291
3292#[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",
"has_delayed_lints"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.owner_id, &self.generics, &self.kind,
&self.impl_kind, &self.span, &&self.has_delayed_lints];
::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>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ImplItem<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ImplItem<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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,
has_delayed_lints: ref __binding_6 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3296pub struct ImplItem<'hir> {
3297 pub ident: Ident,
3298 pub owner_id: OwnerId,
3299 pub generics: &'hir Generics<'hir>,
3300 pub kind: ImplItemKind<'hir>,
3301 pub impl_kind: ImplItemImplKind,
3302 pub span: Span,
3303 pub has_delayed_lints: bool,
3304}
3305
3306#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ImplItemImplKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ImplItemImplKind::Inherent { vis_span: ref __binding_0 } =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ImplItemImplKind::Trait {
defaultness: ref __binding_0,
trait_item_def_id: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3307pub enum ImplItemImplKind {
3308 Inherent {
3309 vis_span: Span,
3310 },
3311 Trait {
3312 defaultness: Defaultness,
3313 trait_item_def_id: Result<DefId, ErrorGuaranteed>,
3315 },
3316}
3317
3318impl<'hir> ImplItem<'hir> {
3319 #[inline]
3320 pub fn hir_id(&self) -> HirId {
3321 HirId::make_owner(self.owner_id.def_id)
3323 }
3324
3325 pub fn impl_item_id(&self) -> ImplItemId {
3326 ImplItemId { owner_id: self.owner_id }
3327 }
3328
3329 pub fn vis_span(&self) -> Option<Span> {
3330 match self.impl_kind {
3331 ImplItemImplKind::Trait { .. } => None,
3332 ImplItemImplKind::Inherent { vis_span, .. } => Some(vis_span),
3333 }
3334 }
3335
3336 self
let ImplItemKind::Type(ty) =
&self.kind else { expect_failed("expect_type", self) };
ty;expect_methods_self_kind! {
3337 expect_const, (&'hir Ty<'hir>, ConstItemRhs<'hir>), ImplItemKind::Const(ty, rhs), (ty, *rhs);
3338 expect_fn, (&FnSig<'hir>, BodyId), ImplItemKind::Fn(ty, body), (ty, *body);
3339 expect_type, &'hir Ty<'hir>, ImplItemKind::Type(ty), ty;
3340 }
3341}
3342
3343#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ImplItemKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ImplItemKind::Const(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ImplItemKind::Fn(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ImplItemKind::Type(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3345pub enum ImplItemKind<'hir> {
3346 Const(&'hir Ty<'hir>, ConstItemRhs<'hir>),
3349 Fn(FnSig<'hir>, BodyId),
3351 Type(&'hir Ty<'hir>),
3353}
3354
3355#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
AssocItemConstraint<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3366pub struct AssocItemConstraint<'hir> {
3367 #[stable_hasher(ignore)]
3368 pub hir_id: HirId,
3369 pub ident: Ident,
3370 pub gen_args: &'hir GenericArgs<'hir>,
3371 pub kind: AssocItemConstraintKind<'hir>,
3372 pub span: Span,
3373}
3374
3375impl<'hir> AssocItemConstraint<'hir> {
3376 pub fn ty(self) -> Option<&'hir Ty<'hir>> {
3378 match self.kind {
3379 AssocItemConstraintKind::Equality { term: Term::Ty(ty) } => Some(ty),
3380 _ => None,
3381 }
3382 }
3383
3384 pub fn ct(self) -> Option<&'hir ConstArg<'hir>> {
3386 match self.kind {
3387 AssocItemConstraintKind::Equality { term: Term::Const(ct) } => Some(ct),
3388 _ => None,
3389 }
3390 }
3391}
3392
3393#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Term<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Term::Ty(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Term::Const(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3394pub enum Term<'hir> {
3395 Ty(&'hir Ty<'hir>),
3396 Const(&'hir ConstArg<'hir>),
3397}
3398
3399impl<'hir> From<&'hir Ty<'hir>> for Term<'hir> {
3400 fn from(ty: &'hir Ty<'hir>) -> Self {
3401 Term::Ty(ty)
3402 }
3403}
3404
3405impl<'hir> From<&'hir ConstArg<'hir>> for Term<'hir> {
3406 fn from(c: &'hir ConstArg<'hir>) -> Self {
3407 Term::Const(c)
3408 }
3409}
3410
3411#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
AssocItemConstraintKind<'hir> where
__CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
AssocItemConstraintKind::Equality { term: ref __binding_0 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
AssocItemConstraintKind::Bound { bounds: ref __binding_0 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3413pub enum AssocItemConstraintKind<'hir> {
3414 Equality { term: Term<'hir> },
3421 Bound { bounds: &'hir [GenericBound<'hir>] },
3423}
3424
3425impl<'hir> AssocItemConstraintKind<'hir> {
3426 pub fn descr(&self) -> &'static str {
3427 match self {
3428 AssocItemConstraintKind::Equality { .. } => "binding",
3429 AssocItemConstraintKind::Bound { .. } => "constraint",
3430 }
3431 }
3432}
3433
3434#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AmbigArg where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {}
}
}
};HashStable_Generic)]
3438pub enum AmbigArg {}
3439
3440#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Ty<'hir, Unambig> where __CTX: crate::HashStableContext,
Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Ty {
hir_id: ref __binding_0,
span: ref __binding_1,
kind: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3445#[repr(C)]
3446pub struct Ty<'hir, Unambig = ()> {
3447 #[stable_hasher(ignore)]
3448 pub hir_id: HirId,
3449 pub span: Span,
3450 pub kind: TyKind<'hir, Unambig>,
3451}
3452
3453impl<'hir> Ty<'hir, AmbigArg> {
3454 pub fn as_unambig_ty(&self) -> &Ty<'hir> {
3465 let ptr = self as *const Ty<'hir, AmbigArg> as *const Ty<'hir, ()>;
3468 unsafe { &*ptr }
3469 }
3470}
3471
3472impl<'hir> Ty<'hir> {
3473 pub fn try_as_ambig_ty(&self) -> Option<&Ty<'hir, AmbigArg>> {
3479 if let TyKind::Infer(()) = self.kind {
3480 return None;
3481 }
3482
3483 let ptr = self as *const Ty<'hir> as *const Ty<'hir, AmbigArg>;
3487 Some(unsafe { &*ptr })
3488 }
3489}
3490
3491impl<'hir> Ty<'hir, AmbigArg> {
3492 pub fn peel_refs(&self) -> &Ty<'hir> {
3493 let mut final_ty = self.as_unambig_ty();
3494 while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3495 final_ty = ty;
3496 }
3497 final_ty
3498 }
3499}
3500
3501impl<'hir> Ty<'hir> {
3502 pub fn peel_refs(&self) -> &Self {
3503 let mut final_ty = self;
3504 while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3505 final_ty = ty;
3506 }
3507 final_ty
3508 }
3509
3510 pub fn as_generic_param(&self) -> Option<(DefId, Ident)> {
3512 let TyKind::Path(QPath::Resolved(None, path)) = self.kind else {
3513 return None;
3514 };
3515 let [segment] = &path.segments else {
3516 return None;
3517 };
3518 match path.res {
3519 Res::Def(DefKind::TyParam, def_id) | Res::SelfTyParam { trait_: def_id } => {
3520 Some((def_id, segment.ident))
3521 }
3522 _ => None,
3523 }
3524 }
3525
3526 pub fn find_self_aliases(&self) -> Vec<Span> {
3527 use crate::intravisit::Visitor;
3528 struct MyVisitor(Vec<Span>);
3529 impl<'v> Visitor<'v> for MyVisitor {
3530 fn visit_ty(&mut self, t: &'v Ty<'v, AmbigArg>) {
3531 if #[allow(non_exhaustive_omitted_patterns)] match &t.kind {
TyKind::Path(QPath::Resolved(_, Path {
res: crate::def::Res::SelfTyAlias { .. }, .. })) => true,
_ => false,
}matches!(
3532 &t.kind,
3533 TyKind::Path(QPath::Resolved(
3534 _,
3535 Path { res: crate::def::Res::SelfTyAlias { .. }, .. },
3536 ))
3537 ) {
3538 self.0.push(t.span);
3539 return;
3540 }
3541 crate::intravisit::walk_ty(self, t);
3542 }
3543 }
3544
3545 let mut my_visitor = MyVisitor(::alloc::vec::Vec::new()vec![]);
3546 my_visitor.visit_ty_unambig(self);
3547 my_visitor.0
3548 }
3549
3550 pub fn is_suggestable_infer_ty(&self) -> bool {
3553 fn are_suggestable_generic_args(generic_args: &[GenericArg<'_>]) -> bool {
3554 generic_args.iter().any(|arg| match arg {
3555 GenericArg::Type(ty) => ty.as_unambig_ty().is_suggestable_infer_ty(),
3556 GenericArg::Infer(_) => true,
3557 _ => false,
3558 })
3559 }
3560 {
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:3560",
"rustc_hir::hir", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir/src/hir.rs"),
::tracing_core::__macro_support::Option::Some(3560u32),
::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);
3561 match &self.kind {
3562 TyKind::Infer(()) => true,
3563 TyKind::Slice(ty) => ty.is_suggestable_infer_ty(),
3564 TyKind::Array(ty, length) => {
3565 ty.is_suggestable_infer_ty() || #[allow(non_exhaustive_omitted_patterns)] match length.kind {
ConstArgKind::Infer(..) => true,
_ => false,
}matches!(length.kind, ConstArgKind::Infer(..))
3566 }
3567 TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
3568 TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),
3569 TyKind::Path(QPath::TypeRelative(ty, segment)) => {
3570 ty.is_suggestable_infer_ty() || are_suggestable_generic_args(segment.args().args)
3571 }
3572 TyKind::Path(QPath::Resolved(ty_opt, Path { segments, .. })) => {
3573 ty_opt.is_some_and(Self::is_suggestable_infer_ty)
3574 || segments
3575 .iter()
3576 .any(|segment| are_suggestable_generic_args(segment.args().args))
3577 }
3578 _ => false,
3579 }
3580 }
3581}
3582
3583#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for PrimTy where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
PrimTy::Int(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PrimTy::Uint(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PrimTy::Float(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PrimTy::Str => {}
PrimTy::Bool => {}
PrimTy::Char => {}
}
}
}
};HashStable_Generic)]
3585pub enum PrimTy {
3586 Int(IntTy),
3587 Uint(UintTy),
3588 Float(FloatTy),
3589 Str,
3590 Bool,
3591 Char,
3592}
3593
3594impl PrimTy {
3595 pub const ALL: [Self; 19] = [
3597 Self::Int(IntTy::I8),
3599 Self::Int(IntTy::I16),
3600 Self::Int(IntTy::I32),
3601 Self::Int(IntTy::I64),
3602 Self::Int(IntTy::I128),
3603 Self::Int(IntTy::Isize),
3604 Self::Uint(UintTy::U8),
3605 Self::Uint(UintTy::U16),
3606 Self::Uint(UintTy::U32),
3607 Self::Uint(UintTy::U64),
3608 Self::Uint(UintTy::U128),
3609 Self::Uint(UintTy::Usize),
3610 Self::Float(FloatTy::F16),
3611 Self::Float(FloatTy::F32),
3612 Self::Float(FloatTy::F64),
3613 Self::Float(FloatTy::F128),
3614 Self::Bool,
3615 Self::Char,
3616 Self::Str,
3617 ];
3618
3619 pub fn name_str(self) -> &'static str {
3623 match self {
3624 PrimTy::Int(i) => i.name_str(),
3625 PrimTy::Uint(u) => u.name_str(),
3626 PrimTy::Float(f) => f.name_str(),
3627 PrimTy::Str => "str",
3628 PrimTy::Bool => "bool",
3629 PrimTy::Char => "char",
3630 }
3631 }
3632
3633 pub fn name(self) -> Symbol {
3634 match self {
3635 PrimTy::Int(i) => i.name(),
3636 PrimTy::Uint(u) => u.name(),
3637 PrimTy::Float(f) => f.name(),
3638 PrimTy::Str => sym::str,
3639 PrimTy::Bool => sym::bool,
3640 PrimTy::Char => sym::char,
3641 }
3642 }
3643
3644 pub fn from_name(name: Symbol) -> Option<Self> {
3647 let ty = match name {
3648 sym::i8 => Self::Int(IntTy::I8),
3650 sym::i16 => Self::Int(IntTy::I16),
3651 sym::i32 => Self::Int(IntTy::I32),
3652 sym::i64 => Self::Int(IntTy::I64),
3653 sym::i128 => Self::Int(IntTy::I128),
3654 sym::isize => Self::Int(IntTy::Isize),
3655 sym::u8 => Self::Uint(UintTy::U8),
3656 sym::u16 => Self::Uint(UintTy::U16),
3657 sym::u32 => Self::Uint(UintTy::U32),
3658 sym::u64 => Self::Uint(UintTy::U64),
3659 sym::u128 => Self::Uint(UintTy::U128),
3660 sym::usize => Self::Uint(UintTy::Usize),
3661 sym::f16 => Self::Float(FloatTy::F16),
3662 sym::f32 => Self::Float(FloatTy::F32),
3663 sym::f64 => Self::Float(FloatTy::F64),
3664 sym::f128 => Self::Float(FloatTy::F128),
3665 sym::bool => Self::Bool,
3666 sym::char => Self::Char,
3667 sym::str => Self::Str,
3668 _ => return None,
3669 };
3670 Some(ty)
3671 }
3672}
3673
3674#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnPtrTy<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3675pub struct FnPtrTy<'hir> {
3676 pub safety: Safety,
3677 pub abi: ExternAbi,
3678 pub generic_params: &'hir [GenericParam<'hir>],
3679 pub decl: &'hir FnDecl<'hir>,
3680 pub param_idents: &'hir [Option<Ident>],
3683}
3684
3685#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
UnsafeBinderTy<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
UnsafeBinderTy {
generic_params: ref __binding_0, inner_ty: ref __binding_1 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3686pub struct UnsafeBinderTy<'hir> {
3687 pub generic_params: &'hir [GenericParam<'hir>],
3688 pub inner_ty: &'hir Ty<'hir>,
3689}
3690
3691#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
OpaqueTy<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3692pub struct OpaqueTy<'hir> {
3693 #[stable_hasher(ignore)]
3694 pub hir_id: HirId,
3695 pub def_id: LocalDefId,
3696 pub bounds: GenericBounds<'hir>,
3697 pub origin: OpaqueTyOrigin<LocalDefId>,
3698 pub span: Span,
3699}
3700
3701#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PreciseCapturingArgKind<T, U> where
__CTX: crate::HashStableContext,
T: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
U: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
PreciseCapturingArgKind::Lifetime(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PreciseCapturingArgKind::Param(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, 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)]
3702pub enum PreciseCapturingArgKind<T, U> {
3703 Lifetime(T),
3704 Param(U),
3706}
3707
3708pub type PreciseCapturingArg<'hir> =
3709 PreciseCapturingArgKind<&'hir Lifetime, PreciseCapturingNonLifetimeArg>;
3710
3711impl PreciseCapturingArg<'_> {
3712 pub fn hir_id(self) -> HirId {
3713 match self {
3714 PreciseCapturingArg::Lifetime(lt) => lt.hir_id,
3715 PreciseCapturingArg::Param(param) => param.hir_id,
3716 }
3717 }
3718
3719 pub fn name(self) -> Symbol {
3720 match self {
3721 PreciseCapturingArg::Lifetime(lt) => lt.ident.name,
3722 PreciseCapturingArg::Param(param) => param.ident.name,
3723 }
3724 }
3725}
3726
3727#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for PreciseCapturingNonLifetimeArg where
__CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
PreciseCapturingNonLifetimeArg {
hir_id: ref __binding_0,
ident: ref __binding_1,
res: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3732pub struct PreciseCapturingNonLifetimeArg {
3733 #[stable_hasher(ignore)]
3734 pub hir_id: HirId,
3735 pub ident: Ident,
3736 pub res: Res,
3737}
3738
3739#[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)]
3740#[derive(const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for RpitContext where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
RpitContext::Trait => {}
RpitContext::TraitImpl => {}
}
}
}
};HashStable_Generic, 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)]
3741pub enum RpitContext {
3742 Trait,
3743 TraitImpl,
3744}
3745
3746#[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)]
3748#[derive(const _: () =
{
impl<D, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
OpaqueTyOrigin<D> where __CTX: crate::HashStableContext,
D: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
OpaqueTyOrigin::FnReturn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
OpaqueTyOrigin::AsyncFn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
OpaqueTyOrigin::TyAlias {
parent: ref __binding_0, in_assoc_ty: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, 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)]
3749pub enum OpaqueTyOrigin<D> {
3750 FnReturn {
3752 parent: D,
3754 in_trait_or_impl: Option<RpitContext>,
3756 },
3757 AsyncFn {
3759 parent: D,
3761 in_trait_or_impl: Option<RpitContext>,
3763 },
3764 TyAlias {
3766 parent: D,
3768 in_assoc_ty: bool,
3770 },
3771}
3772
3773#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DelegationGenerics {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DelegationGenerics", "parent_args_segment_id",
&self.parent_args_segment_id, "child_args_segment_id",
&&self.child_args_segment_id)
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for DelegationGenerics {
#[inline]
fn clone(&self) -> DelegationGenerics {
let _: ::core::clone::AssertParamIsClone<Option<HirId>>;
let _: ::core::clone::AssertParamIsClone<Option<HirId>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DelegationGenerics { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for DelegationGenerics {
#[inline]
fn eq(&self, other: &DelegationGenerics) -> bool {
self.parent_args_segment_id == other.parent_args_segment_id &&
self.child_args_segment_id == other.child_args_segment_id
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DelegationGenerics {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Option<HirId>>;
let _: ::core::cmp::AssertParamIsEq<Option<HirId>>;
}
}Eq, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for DelegationGenerics where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
DelegationGenerics {
parent_args_segment_id: ref __binding_0,
child_args_segment_id: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3775pub struct DelegationGenerics {
3776 pub parent_args_segment_id: Option<HirId>,
3777 pub child_args_segment_id: Option<HirId>,
3778}
3779
3780#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InferDelegationKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
InferDelegationKind::Input(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Input",
&__self_0),
InferDelegationKind::Output(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Output",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InferDelegationKind<'hir> {
#[inline]
fn clone(&self) -> InferDelegationKind<'hir> {
let _: ::core::clone::AssertParamIsClone<usize>;
let _: ::core::clone::AssertParamIsClone<&'hir DelegationGenerics>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InferDelegationKind<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::cmp::PartialEq for InferDelegationKind<'hir> {
#[inline]
fn eq(&self, other: &InferDelegationKind<'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) {
(InferDelegationKind::Input(__self_0),
InferDelegationKind::Input(__arg1_0)) =>
__self_0 == __arg1_0,
(InferDelegationKind::Output(__self_0),
InferDelegationKind::Output(__arg1_0)) =>
__self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl<'hir> ::core::cmp::Eq for InferDelegationKind<'hir> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<usize>;
let _: ::core::cmp::AssertParamIsEq<&'hir DelegationGenerics>;
}
}Eq, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
InferDelegationKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
InferDelegationKind::Input(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
InferDelegationKind::Output(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3781pub enum InferDelegationKind<'hir> {
3782 Input(usize),
3783 Output(&'hir DelegationGenerics),
3785}
3786
3787#[repr(u8, C)]
3793#[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, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"InferDelegation", __self_0, &__self_1),
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, __self_1) =>
TyKind::InferDelegation(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TyKind<'hir, Unambig> where __CTX: crate::HashStableContext,
Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
TyKind::InferDelegation(ref __binding_0, ref __binding_1) =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Slice(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Array(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Ptr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Ref(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::FnPtr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::UnsafeBinder(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Never => {}
TyKind::Tup(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Path(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::OpaqueDef(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::TraitAscription(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::TraitObject(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Pat(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::FieldOf(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Infer(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3794pub enum TyKind<'hir, Unambig = ()> {
3795 InferDelegation(DefId, InferDelegationKind<'hir>),
3797 Slice(&'hir Ty<'hir>),
3799 Array(&'hir Ty<'hir>, &'hir ConstArg<'hir>),
3801 Ptr(MutTy<'hir>),
3803 Ref(&'hir Lifetime, MutTy<'hir>),
3805 FnPtr(&'hir FnPtrTy<'hir>),
3807 UnsafeBinder(&'hir UnsafeBinderTy<'hir>),
3809 Never,
3811 Tup(&'hir [Ty<'hir>]),
3813 Path(QPath<'hir>),
3818 OpaqueDef(&'hir OpaqueTy<'hir>),
3820 TraitAscription(GenericBounds<'hir>),
3822 TraitObject(&'hir [PolyTraitRef<'hir>], TaggedRef<'hir, Lifetime, TraitObjectSyntax>),
3828 Err(rustc_span::ErrorGuaranteed),
3830 Pat(&'hir Ty<'hir>, &'hir TyPat<'hir>),
3832 FieldOf(&'hir Ty<'hir>, &'hir TyFieldPath),
3836 Infer(Unambig),
3842}
3843
3844#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
InlineAsmOperand<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
InlineAsmOperand::In {
reg: ref __binding_0, expr: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::Out {
reg: ref __binding_0,
late: ref __binding_1,
expr: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::InOut {
reg: ref __binding_0,
late: ref __binding_1,
expr: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::SplitInOut {
reg: ref __binding_0,
late: ref __binding_1,
in_expr: ref __binding_2,
out_expr: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::Const { anon_const: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::SymFn { expr: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::SymStatic {
path: ref __binding_0, def_id: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::Label { block: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3845pub enum InlineAsmOperand<'hir> {
3846 In {
3847 reg: InlineAsmRegOrRegClass,
3848 expr: &'hir Expr<'hir>,
3849 },
3850 Out {
3851 reg: InlineAsmRegOrRegClass,
3852 late: bool,
3853 expr: Option<&'hir Expr<'hir>>,
3854 },
3855 InOut {
3856 reg: InlineAsmRegOrRegClass,
3857 late: bool,
3858 expr: &'hir Expr<'hir>,
3859 },
3860 SplitInOut {
3861 reg: InlineAsmRegOrRegClass,
3862 late: bool,
3863 in_expr: &'hir Expr<'hir>,
3864 out_expr: Option<&'hir Expr<'hir>>,
3865 },
3866 Const {
3867 anon_const: ConstBlock,
3868 },
3869 SymFn {
3870 expr: &'hir Expr<'hir>,
3871 },
3872 SymStatic {
3873 path: QPath<'hir>,
3874 def_id: DefId,
3875 },
3876 Label {
3877 block: &'hir Block<'hir>,
3878 },
3879}
3880
3881impl<'hir> InlineAsmOperand<'hir> {
3882 pub fn reg(&self) -> Option<InlineAsmRegOrRegClass> {
3883 match *self {
3884 Self::In { reg, .. }
3885 | Self::Out { reg, .. }
3886 | Self::InOut { reg, .. }
3887 | Self::SplitInOut { reg, .. } => Some(reg),
3888 Self::Const { .. }
3889 | Self::SymFn { .. }
3890 | Self::SymStatic { .. }
3891 | Self::Label { .. } => None,
3892 }
3893 }
3894
3895 pub fn is_clobber(&self) -> bool {
3896 #[allow(non_exhaustive_omitted_patterns)] match self {
InlineAsmOperand::Out {
reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None } => true,
_ => false,
}matches!(
3897 self,
3898 InlineAsmOperand::Out { reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None }
3899 )
3900 }
3901}
3902
3903#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
InlineAsm<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3904pub struct InlineAsm<'hir> {
3905 pub asm_macro: ast::AsmMacro,
3906 pub template: &'hir [InlineAsmTemplatePiece],
3907 pub template_strs: &'hir [(Symbol, Option<Symbol>, Span)],
3908 pub operands: &'hir [(InlineAsmOperand<'hir>, Span)],
3909 pub options: InlineAsmOptions,
3910 pub line_spans: &'hir [Span],
3911}
3912
3913impl InlineAsm<'_> {
3914 pub fn contains_label(&self) -> bool {
3915 self.operands.iter().any(|x| #[allow(non_exhaustive_omitted_patterns)] match x.0 {
InlineAsmOperand::Label { .. } => true,
_ => false,
}matches!(x.0, InlineAsmOperand::Label { .. }))
3916 }
3917}
3918
3919#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Param<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Param {
hir_id: ref __binding_0,
pat: ref __binding_1,
ty_span: ref __binding_2,
span: ref __binding_3 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3921pub struct Param<'hir> {
3922 #[stable_hasher(ignore)]
3923 pub hir_id: HirId,
3924 pub pat: &'hir Pat<'hir>,
3925 pub ty_span: Span,
3926 pub span: Span,
3927}
3928
3929#[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_field5_finish(f, "FnDecl",
"inputs", &self.inputs, "output", &self.output, "c_variadic",
&self.c_variadic, "implicit_self", &self.implicit_self,
"lifetime_elision_allowed", &&self.lifetime_elision_allowed)
}
}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<bool>;
let _: ::core::clone::AssertParamIsClone<ImplicitSelfKind>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnDecl<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnDecl<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FnDecl {
inputs: ref __binding_0,
output: ref __binding_1,
c_variadic: ref __binding_2,
implicit_self: ref __binding_3,
lifetime_elision_allowed: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3931pub struct FnDecl<'hir> {
3932 pub inputs: &'hir [Ty<'hir>],
3936 pub output: FnRetTy<'hir>,
3937 pub c_variadic: bool,
3938 pub implicit_self: ImplicitSelfKind,
3940 pub lifetime_elision_allowed: bool,
3942}
3943
3944impl<'hir> FnDecl<'hir> {
3945 pub fn opt_delegation_sig_id(&self) -> Option<DefId> {
3946 if let FnRetTy::Return(ty) = self.output
3947 && let TyKind::InferDelegation(sig_id, _) = ty.kind
3948 {
3949 return Some(sig_id);
3950 }
3951 None
3952 }
3953
3954 pub fn opt_delegation_generics(&self) -> Option<&'hir DelegationGenerics> {
3955 if let FnRetTy::Return(ty) = self.output
3956 && let TyKind::InferDelegation(_, kind) = ty.kind
3957 && let InferDelegationKind::Output(generics) = kind
3958 {
3959 return Some(generics);
3960 }
3961
3962 None
3963 }
3964}
3965
3966#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ImplicitSelfKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ImplicitSelfKind::Imm => {}
ImplicitSelfKind::Mut => {}
ImplicitSelfKind::RefImm => {}
ImplicitSelfKind::RefMut => {}
ImplicitSelfKind::None => {}
}
}
}
};HashStable_Generic)]
3968pub enum ImplicitSelfKind {
3969 Imm,
3971 Mut,
3973 RefImm,
3975 RefMut,
3977 None,
3980}
3981
3982impl ImplicitSelfKind {
3983 pub fn has_implicit_self(&self) -> bool {
3985 !#[allow(non_exhaustive_omitted_patterns)] match *self {
ImplicitSelfKind::None => true,
_ => false,
}matches!(*self, ImplicitSelfKind::None)
3986 }
3987}
3988
3989#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for IsAsync where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
IsAsync::Async(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
IsAsync::NotAsync => {}
}
}
}
};HashStable_Generic)]
3990pub enum IsAsync {
3991 Async(Span),
3992 NotAsync,
3993}
3994
3995impl IsAsync {
3996 pub fn is_async(self) -> bool {
3997 #[allow(non_exhaustive_omitted_patterns)] match self {
IsAsync::Async(_) => true,
_ => false,
}matches!(self, IsAsync::Async(_))
3998 }
3999}
4000
4001#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Defaultness where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Defaultness::Default { has_value: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Defaultness::Final => {}
}
}
}
};HashStable_Generic)]
4002#[derive(#[automatically_derived]
impl ::core::default::Default for Defaultness {
#[inline]
fn default() -> Defaultness { Self::Final }
}Default)]
4003pub enum Defaultness {
4004 Default {
4005 has_value: bool,
4006 },
4007 #[default]
4008 Final,
4009}
4010
4011impl Defaultness {
4012 pub fn has_value(&self) -> bool {
4013 match *self {
4014 Defaultness::Default { has_value } => has_value,
4015 Defaultness::Final => true,
4016 }
4017 }
4018
4019 pub fn is_final(&self) -> bool {
4020 *self == Defaultness::Final
4021 }
4022
4023 pub fn is_default(&self) -> bool {
4024 #[allow(non_exhaustive_omitted_patterns)] match *self {
Defaultness::Default { .. } => true,
_ => false,
}matches!(*self, Defaultness::Default { .. })
4025 }
4026}
4027
4028#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnRetTy<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
FnRetTy::DefaultReturn(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
FnRetTy::Return(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4029pub enum FnRetTy<'hir> {
4030 DefaultReturn(Span),
4036 Return(&'hir Ty<'hir>),
4038}
4039
4040impl<'hir> FnRetTy<'hir> {
4041 #[inline]
4042 pub fn span(&self) -> Span {
4043 match *self {
4044 Self::DefaultReturn(span) => span,
4045 Self::Return(ref ty) => ty.span,
4046 }
4047 }
4048
4049 pub fn is_suggestable_infer_ty(&self) -> Option<&'hir Ty<'hir>> {
4050 if let Self::Return(ty) = self
4051 && ty.is_suggestable_infer_ty()
4052 {
4053 return Some(*ty);
4054 }
4055 None
4056 }
4057}
4058
4059#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ClosureBinder where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ClosureBinder::Default => {}
ClosureBinder::For { span: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4061pub enum ClosureBinder {
4062 Default,
4064 For { span: Span },
4068}
4069
4070#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Mod<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Mod { spans: ref __binding_0, item_ids: ref __binding_1 } =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4071pub struct Mod<'hir> {
4072 pub spans: ModSpans,
4073 pub item_ids: &'hir [ItemId],
4074}
4075
4076#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ModSpans where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ModSpans {
inner_span: ref __binding_0,
inject_use_span: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4077pub struct ModSpans {
4078 pub inner_span: Span,
4082 pub inject_use_span: Span,
4083}
4084
4085#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
EnumDef<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
EnumDef { variants: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4086pub struct EnumDef<'hir> {
4087 pub variants: &'hir [Variant<'hir>],
4088}
4089
4090#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Variant<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{}
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4091pub struct Variant<'hir> {
4092 pub ident: Ident,
4094 #[stable_hasher(ignore)]
4096 pub hir_id: HirId,
4097 pub def_id: LocalDefId,
4098 pub data: VariantData<'hir>,
4100 pub disr_expr: Option<&'hir AnonConst>,
4102 pub span: Span,
4104}
4105
4106#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for UseKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
UseKind::Single(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
UseKind::Glob => {}
UseKind::ListStem => {}
}
}
}
};HashStable_Generic)]
4107pub enum UseKind {
4108 Single(Ident),
4115
4116 Glob,
4118
4119 ListStem,
4123}
4124
4125#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitRef<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitRef {
path: ref __binding_0, hir_ref_id: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{}
}
}
}
}
};HashStable_Generic)]
4132pub struct TraitRef<'hir> {
4133 pub path: &'hir Path<'hir>,
4134 #[stable_hasher(ignore)]
4136 pub hir_ref_id: HirId,
4137}
4138
4139impl TraitRef<'_> {
4140 pub fn trait_def_id(&self) -> Option<DefId> {
4142 match self.path.res {
4143 Res::Def(DefKind::Trait | DefKind::TraitAlias, did) => Some(did),
4144 Res::Err => None,
4145 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"),
4146 }
4147 }
4148}
4149
4150#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PolyTraitRef<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4151pub struct PolyTraitRef<'hir> {
4152 pub bound_generic_params: &'hir [GenericParam<'hir>],
4154
4155 pub modifiers: TraitBoundModifiers,
4159
4160 pub trait_ref: TraitRef<'hir>,
4162
4163 pub span: Span,
4164}
4165
4166#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FieldDef<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{}
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
{ __binding_7.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4167pub struct FieldDef<'hir> {
4168 pub span: Span,
4169 pub vis_span: Span,
4170 pub ident: Ident,
4171 #[stable_hasher(ignore)]
4172 pub hir_id: HirId,
4173 pub def_id: LocalDefId,
4174 pub ty: &'hir Ty<'hir>,
4175 pub safety: Safety,
4176 pub default: Option<&'hir AnonConst>,
4177}
4178
4179impl FieldDef<'_> {
4180 pub fn is_positional(&self) -> bool {
4182 self.ident.as_str().as_bytes()[0].is_ascii_digit()
4183 }
4184}
4185
4186#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
VariantData<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
VariantData::Struct {
fields: ref __binding_0, recovered: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
VariantData::Tuple(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{}
{ __binding_2.hash_stable(__hcx, __hasher); }
}
VariantData::Unit(ref __binding_0, ref __binding_1) => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4188pub enum VariantData<'hir> {
4189 Struct { fields: &'hir [FieldDef<'hir>], recovered: ast::Recovered },
4193 Tuple(&'hir [FieldDef<'hir>], #[stable_hasher(ignore)] HirId, LocalDefId),
4197 Unit(#[stable_hasher(ignore)] HirId, LocalDefId),
4201}
4202
4203impl<'hir> VariantData<'hir> {
4204 pub fn fields(&self) -> &'hir [FieldDef<'hir>] {
4206 match *self {
4207 VariantData::Struct { fields, .. } | VariantData::Tuple(fields, ..) => fields,
4208 _ => &[],
4209 }
4210 }
4211
4212 pub fn ctor(&self) -> Option<(CtorKind, HirId, LocalDefId)> {
4213 match *self {
4214 VariantData::Tuple(_, hir_id, def_id) => Some((CtorKind::Fn, hir_id, def_id)),
4215 VariantData::Unit(hir_id, def_id) => Some((CtorKind::Const, hir_id, def_id)),
4216 VariantData::Struct { .. } => None,
4217 }
4218 }
4219
4220 #[inline]
4221 pub fn ctor_kind(&self) -> Option<CtorKind> {
4222 self.ctor().map(|(kind, ..)| kind)
4223 }
4224
4225 #[inline]
4227 pub fn ctor_hir_id(&self) -> Option<HirId> {
4228 self.ctor().map(|(_, hir_id, _)| hir_id)
4229 }
4230
4231 #[inline]
4233 pub fn ctor_def_id(&self) -> Option<LocalDefId> {
4234 self.ctor().map(|(.., def_id)| def_id)
4235 }
4236}
4237
4238#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ItemId where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ItemId { owner_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4242pub struct ItemId {
4243 pub owner_id: OwnerId,
4244}
4245
4246impl ItemId {
4247 #[inline]
4248 pub fn hir_id(&self) -> HirId {
4249 HirId::make_owner(self.owner_id.def_id)
4251 }
4252}
4253
4254#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Item<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["owner_id", "kind", "span", "vis_span", "has_delayed_lints",
"eii"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.owner_id, &self.kind, &self.span, &self.vis_span,
&self.has_delayed_lints, &&self.eii];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Item", names,
values)
}
}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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Item<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Item {
owner_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2,
vis_span: ref __binding_3,
has_delayed_lints: ref __binding_4,
eii: ref __binding_5 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4263pub struct Item<'hir> {
4264 pub owner_id: OwnerId,
4265 pub kind: ItemKind<'hir>,
4266 pub span: Span,
4267 pub vis_span: Span,
4268 pub has_delayed_lints: bool,
4269 pub eii: bool,
4272}
4273
4274impl<'hir> Item<'hir> {
4275 #[inline]
4276 pub fn hir_id(&self) -> HirId {
4277 HirId::make_owner(self.owner_id.def_id)
4279 }
4280
4281 pub fn item_id(&self) -> ItemId {
4282 ItemId { owner_id: self.owner_id }
4283 }
4284
4285 pub fn is_adt(&self) -> bool {
4288 #[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(..))
4289 }
4290
4291 pub fn is_struct_or_union(&self) -> bool {
4293 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ItemKind::Struct(..) | ItemKind::Union(..) => true,
_ => false,
}matches!(self.kind, ItemKind::Struct(..) | ItemKind::Union(..))
4294 }
4295
4296 self
let ItemKind::Impl(imp) =
&self.kind else { expect_failed("expect_impl", self) };
imp;expect_methods_self_kind! {
4297 expect_extern_crate, (Option<Symbol>, Ident),
4298 ItemKind::ExternCrate(s, ident), (*s, *ident);
4299
4300 expect_use, (&'hir UsePath<'hir>, UseKind), ItemKind::Use(p, uk), (p, *uk);
4301
4302 expect_static, (Mutability, Ident, &'hir Ty<'hir>, BodyId),
4303 ItemKind::Static(mutbl, ident, ty, body), (*mutbl, *ident, ty, *body);
4304
4305 expect_const, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4306 ItemKind::Const(ident, generics, ty, rhs), (*ident, generics, ty, *rhs);
4307
4308 expect_fn, (Ident, &FnSig<'hir>, &'hir Generics<'hir>, BodyId),
4309 ItemKind::Fn { ident, sig, generics, body, .. }, (*ident, sig, generics, *body);
4310
4311 expect_macro, (Ident, &ast::MacroDef, MacroKinds),
4312 ItemKind::Macro(ident, def, mk), (*ident, def, *mk);
4313
4314 expect_mod, (Ident, &'hir Mod<'hir>), ItemKind::Mod(ident, m), (*ident, m);
4315
4316 expect_foreign_mod, (ExternAbi, &'hir [ForeignItemId]),
4317 ItemKind::ForeignMod { abi, items }, (*abi, items);
4318
4319 expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm { asm, .. }, asm;
4320
4321 expect_ty_alias, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4322 ItemKind::TyAlias(ident, generics, ty), (*ident, generics, ty);
4323
4324 expect_enum, (Ident, &'hir Generics<'hir>, &EnumDef<'hir>),
4325 ItemKind::Enum(ident, generics, def), (*ident, generics, def);
4326
4327 expect_struct, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4328 ItemKind::Struct(ident, generics, data), (*ident, generics, data);
4329
4330 expect_union, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4331 ItemKind::Union(ident, generics, data), (*ident, generics, data);
4332
4333 expect_trait,
4334 (
4335 Constness,
4336 IsAuto,
4337 Safety,
4338 Ident,
4339 &'hir Generics<'hir>,
4340 GenericBounds<'hir>,
4341 &'hir [TraitItemId]
4342 ),
4343 ItemKind::Trait(constness, is_auto, safety, ident, generics, bounds, items),
4344 (*constness, *is_auto, *safety, *ident, generics, bounds, items);
4345
4346 expect_trait_alias, (Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4347 ItemKind::TraitAlias(constness, ident, generics, bounds), (*constness, *ident, generics, bounds);
4348
4349 expect_impl, &Impl<'hir>, ItemKind::Impl(imp), imp;
4350 }
4351}
4352
4353#[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> {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
}
}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)]
4354#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Safety where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self { Safety::Unsafe => {} Safety::Safe => {} }
}
}
};HashStable_Generic, #[automatically_derived]
impl ::core::default::Default for Safety {
#[inline]
fn default() -> Safety { Self::Unsafe }
}Default)]
4355pub enum Safety {
4356 #[default]
4361 Unsafe,
4362 Safe,
4363}
4364
4365impl Safety {
4366 pub fn prefix_str(self) -> &'static str {
4367 match self {
4368 Self::Unsafe => "unsafe ",
4369 Self::Safe => "",
4370 }
4371 }
4372
4373 #[inline]
4374 pub fn is_unsafe(self) -> bool {
4375 !self.is_safe()
4376 }
4377
4378 #[inline]
4379 pub fn is_safe(self) -> bool {
4380 match self {
4381 Self::Unsafe => false,
4382 Self::Safe => true,
4383 }
4384 }
4385}
4386
4387impl fmt::Display for Safety {
4388 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4389 f.write_str(match *self {
4390 Self::Unsafe => "unsafe",
4391 Self::Safe => "safe",
4392 })
4393 }
4394}
4395
4396#[derive(#[automatically_derived]
impl ::core::marker::Copy for Constness { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Constness {
#[inline]
fn clone(&self) -> Constness { *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
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Constness {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for Constness {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
Constness::Const => "Const",
Constness::NotConst => "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 => { 0usize }
Constness::NotConst => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Constness::Const => {}
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 }
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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Constness where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Constness::Const => {}
Constness::NotConst => {}
}
}
}
};HashStable_Generic)]
4397#[derive(#[automatically_derived]
impl ::core::default::Default for Constness {
#[inline]
fn default() -> Constness { Self::Const }
}Default)]
4398pub enum Constness {
4399 #[default]
4400 Const,
4401 NotConst,
4402}
4403
4404impl fmt::Display for Constness {
4405 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4406 f.write_str(match *self {
4407 Self::Const => "const",
4408 Self::NotConst => "non-const",
4409 })
4410 }
4411}
4412
4413#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for HeaderSafety where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
HeaderSafety::SafeTargetFeatures => {}
HeaderSafety::Normal(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, #[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)]
4418pub enum HeaderSafety {
4419 SafeTargetFeatures,
4425 Normal(Safety),
4426}
4427
4428impl From<Safety> for HeaderSafety {
4429 fn from(v: Safety) -> Self {
4430 Self::Normal(v)
4431 }
4432}
4433
4434#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for FnHeader where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FnHeader {
safety: ref __binding_0,
constness: ref __binding_1,
asyncness: ref __binding_2,
abi: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4435pub struct FnHeader {
4436 pub safety: HeaderSafety,
4437 pub constness: Constness,
4438 pub asyncness: IsAsync,
4439 pub abi: ExternAbi,
4440}
4441
4442impl FnHeader {
4443 pub fn is_async(&self) -> bool {
4444 #[allow(non_exhaustive_omitted_patterns)] match self.asyncness {
IsAsync::Async(_) => true,
_ => false,
}matches!(self.asyncness, IsAsync::Async(_))
4445 }
4446
4447 pub fn is_const(&self) -> bool {
4448 #[allow(non_exhaustive_omitted_patterns)] match self.constness {
Constness::Const => true,
_ => false,
}matches!(self.constness, Constness::Const)
4449 }
4450
4451 pub fn is_unsafe(&self) -> bool {
4452 self.safety().is_unsafe()
4453 }
4454
4455 pub fn is_safe(&self) -> bool {
4456 self.safety().is_safe()
4457 }
4458
4459 pub fn safety(&self) -> Safety {
4460 match self.safety {
4461 HeaderSafety::SafeTargetFeatures => Safety::Unsafe,
4462 HeaderSafety::Normal(safety) => safety,
4463 }
4464 }
4465}
4466
4467#[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(__self_0, __self_1, __self_2, __self_3, __self_4,
__self_5, __self_6) => {
let values: &[&dyn ::core::fmt::Debug] =
&[__self_0, __self_1, __self_2, __self_3, __self_4,
__self_5, &__self_6];
::core::fmt::Formatter::debug_tuple_fields_finish(f, "Trait",
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<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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ItemKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ItemKind::ExternCrate(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ItemKind::Use(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ItemKind::Static(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
ItemKind::Const(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
ItemKind::Macro(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ItemKind::Mod(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ItemKind::ForeignMod {
abi: ref __binding_0, items: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ItemKind::GlobalAsm {
asm: ref __binding_0, fake_body: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ItemKind::TyAlias(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ItemKind::Enum(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ItemKind::Struct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ItemKind::Union(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ItemKind::Trait(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3, ref __binding_4,
ref __binding_5, ref __binding_6) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
}
ItemKind::TraitAlias(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
ItemKind::Impl(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4468pub enum ItemKind<'hir> {
4469 ExternCrate(Option<Symbol>, Ident),
4473
4474 Use(&'hir UsePath<'hir>, UseKind),
4480
4481 Static(Mutability, Ident, &'hir Ty<'hir>, BodyId),
4483 Const(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4485 Fn {
4487 sig: FnSig<'hir>,
4488 ident: Ident,
4489 generics: &'hir Generics<'hir>,
4490 body: BodyId,
4491 has_body: bool,
4495 },
4496 Macro(Ident, &'hir ast::MacroDef, MacroKinds),
4498 Mod(Ident, &'hir Mod<'hir>),
4500 ForeignMod { abi: ExternAbi, items: &'hir [ForeignItemId] },
4502 GlobalAsm {
4504 asm: &'hir InlineAsm<'hir>,
4505 fake_body: BodyId,
4511 },
4512 TyAlias(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4514 Enum(Ident, &'hir Generics<'hir>, EnumDef<'hir>),
4516 Struct(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4518 Union(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4520 Trait(
4522 Constness,
4523 IsAuto,
4524 Safety,
4525 Ident,
4526 &'hir Generics<'hir>,
4527 GenericBounds<'hir>,
4528 &'hir [TraitItemId],
4529 ),
4530 TraitAlias(Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4532
4533 Impl(Impl<'hir>),
4535}
4536
4537#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Impl<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4542pub struct Impl<'hir> {
4543 pub generics: &'hir Generics<'hir>,
4544 pub of_trait: Option<&'hir TraitImplHeader<'hir>>,
4545 pub self_ty: &'hir Ty<'hir>,
4546 pub items: &'hir [ImplItemId],
4547 pub constness: Constness,
4548}
4549
4550#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitImplHeader<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4551pub struct TraitImplHeader<'hir> {
4552 pub safety: Safety,
4553 pub polarity: ImplPolarity,
4554 pub defaultness: Defaultness,
4555 pub defaultness_span: Option<Span>,
4558 pub trait_ref: TraitRef<'hir>,
4559}
4560
4561impl ItemKind<'_> {
4562 pub fn ident(&self) -> Option<Ident> {
4563 match *self {
4564 ItemKind::ExternCrate(_, ident)
4565 | ItemKind::Use(_, UseKind::Single(ident))
4566 | ItemKind::Static(_, ident, ..)
4567 | ItemKind::Const(ident, ..)
4568 | ItemKind::Fn { ident, .. }
4569 | ItemKind::Macro(ident, ..)
4570 | ItemKind::Mod(ident, ..)
4571 | ItemKind::TyAlias(ident, ..)
4572 | ItemKind::Enum(ident, ..)
4573 | ItemKind::Struct(ident, ..)
4574 | ItemKind::Union(ident, ..)
4575 | ItemKind::Trait(_, _, _, ident, ..)
4576 | ItemKind::TraitAlias(_, ident, ..) => Some(ident),
4577
4578 ItemKind::Use(_, UseKind::Glob | UseKind::ListStem)
4579 | ItemKind::ForeignMod { .. }
4580 | ItemKind::GlobalAsm { .. }
4581 | ItemKind::Impl(_) => None,
4582 }
4583 }
4584
4585 pub fn generics(&self) -> Option<&Generics<'_>> {
4586 Some(match self {
4587 ItemKind::Fn { generics, .. }
4588 | ItemKind::TyAlias(_, generics, _)
4589 | ItemKind::Const(_, generics, _, _)
4590 | ItemKind::Enum(_, generics, _)
4591 | ItemKind::Struct(_, generics, _)
4592 | ItemKind::Union(_, generics, _)
4593 | ItemKind::Trait(_, _, _, _, generics, _, _)
4594 | ItemKind::TraitAlias(_, _, generics, _)
4595 | ItemKind::Impl(Impl { generics, .. }) => generics,
4596 _ => return None,
4597 })
4598 }
4599
4600 pub fn recovered(&self) -> bool {
4601 match self {
4602 ItemKind::Struct(
4603 _,
4604 _,
4605 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4606 ) => true,
4607 ItemKind::Union(
4608 _,
4609 _,
4610 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4611 ) => true,
4612 ItemKind::Enum(_, _, def) => def.variants.iter().any(|v| match v.data {
4613 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. } => true,
4614 _ => false,
4615 }),
4616 _ => false,
4617 }
4618 }
4619}
4620
4621#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ForeignItemId where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ForeignItemId { owner_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4625pub struct ForeignItemId {
4626 pub owner_id: OwnerId,
4627}
4628
4629impl ForeignItemId {
4630 #[inline]
4631 pub fn hir_id(&self) -> HirId {
4632 HirId::make_owner(self.owner_id.def_id)
4634 }
4635}
4636
4637#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ForeignItem<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["ident", "kind", "owner_id", "span", "vis_span",
"has_delayed_lints"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.kind, &self.owner_id, &self.span,
&self.vis_span, &&self.has_delayed_lints];
::core::fmt::Formatter::debug_struct_fields_finish(f, "ForeignItem",
names, values)
}
}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>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ForeignItem<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ForeignItem<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::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,
has_delayed_lints: ref __binding_5 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4638pub struct ForeignItem<'hir> {
4639 pub ident: Ident,
4640 pub kind: ForeignItemKind<'hir>,
4641 pub owner_id: OwnerId,
4642 pub span: Span,
4643 pub vis_span: Span,
4644 pub has_delayed_lints: bool,
4645}
4646
4647impl ForeignItem<'_> {
4648 #[inline]
4649 pub fn hir_id(&self) -> HirId {
4650 HirId::make_owner(self.owner_id.def_id)
4652 }
4653
4654 pub fn foreign_item_id(&self) -> ForeignItemId {
4655 ForeignItemId { owner_id: self.owner_id }
4656 }
4657}
4658
4659#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ForeignItemKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ForeignItemKind::Fn(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ForeignItemKind::Static(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ForeignItemKind::Type => {}
}
}
}
};HashStable_Generic)]
4661pub enum ForeignItemKind<'hir> {
4662 Fn(FnSig<'hir>, &'hir [Option<Ident>], &'hir Generics<'hir>),
4669 Static(&'hir Ty<'hir>, Mutability, Safety),
4671 Type,
4673}
4674
4675#[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Upvar where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Upvar { span: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4677pub struct Upvar {
4678 pub span: Span,
4680}
4681
4682#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitCandidate<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitCandidate {
def_id: ref __binding_0,
import_ids: ref __binding_1,
lint_ambiguous: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4686pub struct TraitCandidate<'hir> {
4687 pub def_id: DefId,
4688 pub import_ids: &'hir [LocalDefId],
4689 pub lint_ambiguous: bool,
4694}
4695
4696#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
OwnerNode<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
OwnerNode::Item(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
OwnerNode::ForeignItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
OwnerNode::TraitItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
OwnerNode::ImplItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
OwnerNode::Crate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
OwnerNode::Synthetic => {}
}
}
}
};HashStable_Generic)]
4697pub enum OwnerNode<'hir> {
4698 Item(&'hir Item<'hir>),
4699 ForeignItem(&'hir ForeignItem<'hir>),
4700 TraitItem(&'hir TraitItem<'hir>),
4701 ImplItem(&'hir ImplItem<'hir>),
4702 Crate(&'hir Mod<'hir>),
4703 Synthetic,
4704}
4705
4706impl<'hir> OwnerNode<'hir> {
4707 pub fn span(&self) -> Span {
4708 match self {
4709 OwnerNode::Item(Item { span, .. })
4710 | OwnerNode::ForeignItem(ForeignItem { span, .. })
4711 | OwnerNode::ImplItem(ImplItem { span, .. })
4712 | OwnerNode::TraitItem(TraitItem { span, .. }) => *span,
4713 OwnerNode::Crate(Mod { spans: ModSpans { inner_span, .. }, .. }) => *inner_span,
4714 OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4715 }
4716 }
4717
4718 pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
4719 match self {
4720 OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4721 | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4722 | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4723 | OwnerNode::ForeignItem(ForeignItem {
4724 kind: ForeignItemKind::Fn(fn_sig, _, _), ..
4725 }) => Some(fn_sig),
4726 _ => None,
4727 }
4728 }
4729
4730 pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
4731 match self {
4732 OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4733 | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4734 | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4735 | OwnerNode::ForeignItem(ForeignItem {
4736 kind: ForeignItemKind::Fn(fn_sig, _, _), ..
4737 }) => Some(fn_sig.decl),
4738 _ => None,
4739 }
4740 }
4741
4742 pub fn body_id(&self) -> Option<BodyId> {
4743 match self {
4744 OwnerNode::Item(Item {
4745 kind:
4746 ItemKind::Static(_, _, _, body)
4747 | ItemKind::Const(.., ConstItemRhs::Body(body))
4748 | ItemKind::Fn { body, .. },
4749 ..
4750 })
4751 | OwnerNode::TraitItem(TraitItem {
4752 kind:
4753 TraitItemKind::Fn(_, TraitFn::Provided(body))
4754 | TraitItemKind::Const(_, Some(ConstItemRhs::Body(body)), _),
4755 ..
4756 })
4757 | OwnerNode::ImplItem(ImplItem {
4758 kind: ImplItemKind::Fn(_, body) | ImplItemKind::Const(_, ConstItemRhs::Body(body)),
4759 ..
4760 }) => Some(*body),
4761 _ => None,
4762 }
4763 }
4764
4765 pub fn generics(self) -> Option<&'hir Generics<'hir>> {
4766 Node::generics(self.into())
4767 }
4768
4769 pub fn def_id(self) -> OwnerId {
4770 match self {
4771 OwnerNode::Item(Item { owner_id, .. })
4772 | OwnerNode::TraitItem(TraitItem { owner_id, .. })
4773 | OwnerNode::ImplItem(ImplItem { owner_id, .. })
4774 | OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
4775 OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
4776 OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4777 }
4778 }
4779
4780 pub fn is_impl_block(&self) -> bool {
4782 #[allow(non_exhaustive_omitted_patterns)] match self {
OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }) => true,
_ => false,
}matches!(self, OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }))
4783 }
4784
4785 self
let OwnerNode::TraitItem(n) =
self else { expect_failed("expect_trait_item", self) };
n;expect_methods_self! {
4786 expect_item, &'hir Item<'hir>, OwnerNode::Item(n), n;
4787 expect_foreign_item, &'hir ForeignItem<'hir>, OwnerNode::ForeignItem(n), n;
4788 expect_impl_item, &'hir ImplItem<'hir>, OwnerNode::ImplItem(n), n;
4789 expect_trait_item, &'hir TraitItem<'hir>, OwnerNode::TraitItem(n), n;
4790 }
4791}
4792
4793impl<'hir> From<&'hir Item<'hir>> for OwnerNode<'hir> {
4794 fn from(val: &'hir Item<'hir>) -> Self {
4795 OwnerNode::Item(val)
4796 }
4797}
4798
4799impl<'hir> From<&'hir ForeignItem<'hir>> for OwnerNode<'hir> {
4800 fn from(val: &'hir ForeignItem<'hir>) -> Self {
4801 OwnerNode::ForeignItem(val)
4802 }
4803}
4804
4805impl<'hir> From<&'hir ImplItem<'hir>> for OwnerNode<'hir> {
4806 fn from(val: &'hir ImplItem<'hir>) -> Self {
4807 OwnerNode::ImplItem(val)
4808 }
4809}
4810
4811impl<'hir> From<&'hir TraitItem<'hir>> for OwnerNode<'hir> {
4812 fn from(val: &'hir TraitItem<'hir>) -> Self {
4813 OwnerNode::TraitItem(val)
4814 }
4815}
4816
4817impl<'hir> From<OwnerNode<'hir>> for Node<'hir> {
4818 fn from(val: OwnerNode<'hir>) -> Self {
4819 match val {
4820 OwnerNode::Item(n) => Node::Item(n),
4821 OwnerNode::ForeignItem(n) => Node::ForeignItem(n),
4822 OwnerNode::ImplItem(n) => Node::ImplItem(n),
4823 OwnerNode::TraitItem(n) => Node::TraitItem(n),
4824 OwnerNode::Crate(n) => Node::Crate(n),
4825 OwnerNode::Synthetic => Node::Synthetic,
4826 }
4827 }
4828}
4829
4830#[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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Node<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Node::Param(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Item(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ForeignItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::TraitItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ImplItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Variant(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Field(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::AnonConst(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ConstBlock(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ConstArg(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Expr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ExprField(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ConstArgExprField(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Stmt(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::PathSegment(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Ty(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::AssocItemConstraint(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::TraitRef(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::OpaqueTy(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::TyPat(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Pat(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::PatField(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::PatExpr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Arm(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Block(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::LetStmt(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Ctor(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Lifetime(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::GenericParam(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Crate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Infer(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::WherePredicate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::PreciseCapturingNonLifetimeArg(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Synthetic => {}
Node::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4831pub enum Node<'hir> {
4832 Param(&'hir Param<'hir>),
4833 Item(&'hir Item<'hir>),
4834 ForeignItem(&'hir ForeignItem<'hir>),
4835 TraitItem(&'hir TraitItem<'hir>),
4836 ImplItem(&'hir ImplItem<'hir>),
4837 Variant(&'hir Variant<'hir>),
4838 Field(&'hir FieldDef<'hir>),
4839 AnonConst(&'hir AnonConst),
4840 ConstBlock(&'hir ConstBlock),
4841 ConstArg(&'hir ConstArg<'hir>),
4842 Expr(&'hir Expr<'hir>),
4843 ExprField(&'hir ExprField<'hir>),
4844 ConstArgExprField(&'hir ConstArgExprField<'hir>),
4845 Stmt(&'hir Stmt<'hir>),
4846 PathSegment(&'hir PathSegment<'hir>),
4847 Ty(&'hir Ty<'hir>),
4848 AssocItemConstraint(&'hir AssocItemConstraint<'hir>),
4849 TraitRef(&'hir TraitRef<'hir>),
4850 OpaqueTy(&'hir OpaqueTy<'hir>),
4851 TyPat(&'hir TyPat<'hir>),
4852 Pat(&'hir Pat<'hir>),
4853 PatField(&'hir PatField<'hir>),
4854 PatExpr(&'hir PatExpr<'hir>),
4858 Arm(&'hir Arm<'hir>),
4859 Block(&'hir Block<'hir>),
4860 LetStmt(&'hir LetStmt<'hir>),
4861 Ctor(&'hir VariantData<'hir>),
4864 Lifetime(&'hir Lifetime),
4865 GenericParam(&'hir GenericParam<'hir>),
4866 Crate(&'hir Mod<'hir>),
4867 Infer(&'hir InferArg),
4868 WherePredicate(&'hir WherePredicate<'hir>),
4869 PreciseCapturingNonLifetimeArg(&'hir PreciseCapturingNonLifetimeArg),
4870 Synthetic,
4872 Err(Span),
4873}
4874
4875impl<'hir> Node<'hir> {
4876 pub fn ident(&self) -> Option<Ident> {
4891 match self {
4892 Node::Item(item) => item.kind.ident(),
4893 Node::TraitItem(TraitItem { ident, .. })
4894 | Node::ImplItem(ImplItem { ident, .. })
4895 | Node::ForeignItem(ForeignItem { ident, .. })
4896 | Node::Field(FieldDef { ident, .. })
4897 | Node::Variant(Variant { ident, .. })
4898 | Node::PathSegment(PathSegment { ident, .. }) => Some(*ident),
4899 Node::Lifetime(lt) => Some(lt.ident),
4900 Node::GenericParam(p) => Some(p.name.ident()),
4901 Node::AssocItemConstraint(c) => Some(c.ident),
4902 Node::PatField(f) => Some(f.ident),
4903 Node::ExprField(f) => Some(f.ident),
4904 Node::ConstArgExprField(f) => Some(f.field),
4905 Node::PreciseCapturingNonLifetimeArg(a) => Some(a.ident),
4906 Node::Param(..)
4907 | Node::AnonConst(..)
4908 | Node::ConstBlock(..)
4909 | Node::ConstArg(..)
4910 | Node::Expr(..)
4911 | Node::Stmt(..)
4912 | Node::Block(..)
4913 | Node::Ctor(..)
4914 | Node::Pat(..)
4915 | Node::TyPat(..)
4916 | Node::PatExpr(..)
4917 | Node::Arm(..)
4918 | Node::LetStmt(..)
4919 | Node::Crate(..)
4920 | Node::Ty(..)
4921 | Node::TraitRef(..)
4922 | Node::OpaqueTy(..)
4923 | Node::Infer(..)
4924 | Node::WherePredicate(..)
4925 | Node::Synthetic
4926 | Node::Err(..) => None,
4927 }
4928 }
4929
4930 pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
4931 match self {
4932 Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4933 | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4934 | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4935 | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
4936 Some(fn_sig.decl)
4937 }
4938 Node::Expr(Expr { kind: ExprKind::Closure(Closure { fn_decl, .. }), .. }) => {
4939 Some(fn_decl)
4940 }
4941 _ => None,
4942 }
4943 }
4944
4945 pub fn impl_block_of_trait(self, trait_def_id: DefId) -> Option<&'hir Impl<'hir>> {
4947 if let Node::Item(Item { kind: ItemKind::Impl(impl_block), .. }) = self
4948 && let Some(of_trait) = impl_block.of_trait
4949 && let Some(trait_id) = of_trait.trait_ref.trait_def_id()
4950 && trait_id == trait_def_id
4951 {
4952 Some(impl_block)
4953 } else {
4954 None
4955 }
4956 }
4957
4958 pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
4959 match self {
4960 Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4961 | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4962 | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4963 | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
4964 Some(fn_sig)
4965 }
4966 _ => None,
4967 }
4968 }
4969
4970 pub fn ty(self) -> Option<&'hir Ty<'hir>> {
4972 match self {
4973 Node::Item(it) => match it.kind {
4974 ItemKind::TyAlias(_, _, ty)
4975 | ItemKind::Static(_, _, ty, _)
4976 | ItemKind::Const(_, _, ty, _) => Some(ty),
4977 ItemKind::Impl(impl_item) => Some(&impl_item.self_ty),
4978 _ => None,
4979 },
4980 Node::TraitItem(it) => match it.kind {
4981 TraitItemKind::Const(ty, _, _) => Some(ty),
4982 TraitItemKind::Type(_, ty) => ty,
4983 _ => None,
4984 },
4985 Node::ImplItem(it) => match it.kind {
4986 ImplItemKind::Const(ty, _) => Some(ty),
4987 ImplItemKind::Type(ty) => Some(ty),
4988 _ => None,
4989 },
4990 Node::ForeignItem(it) => match it.kind {
4991 ForeignItemKind::Static(ty, ..) => Some(ty),
4992 _ => None,
4993 },
4994 Node::GenericParam(param) => match param.kind {
4995 GenericParamKind::Lifetime { .. } => None,
4996 GenericParamKind::Type { default, .. } => default,
4997 GenericParamKind::Const { ty, .. } => Some(ty),
4998 },
4999 _ => None,
5000 }
5001 }
5002
5003 pub fn alias_ty(self) -> Option<&'hir Ty<'hir>> {
5004 match self {
5005 Node::Item(Item { kind: ItemKind::TyAlias(_, _, ty), .. }) => Some(ty),
5006 _ => None,
5007 }
5008 }
5009
5010 #[inline]
5011 pub fn associated_body(&self) -> Option<(LocalDefId, BodyId)> {
5012 match self {
5013 Node::Item(Item {
5014 owner_id,
5015 kind:
5016 ItemKind::Const(.., ConstItemRhs::Body(body))
5017 | ItemKind::Static(.., body)
5018 | ItemKind::Fn { body, .. },
5019 ..
5020 })
5021 | Node::TraitItem(TraitItem {
5022 owner_id,
5023 kind:
5024 TraitItemKind::Const(_, Some(ConstItemRhs::Body(body)), _)
5025 | TraitItemKind::Fn(_, TraitFn::Provided(body)),
5026 ..
5027 })
5028 | Node::ImplItem(ImplItem {
5029 owner_id,
5030 kind: ImplItemKind::Const(.., ConstItemRhs::Body(body)) | ImplItemKind::Fn(_, body),
5031 ..
5032 }) => Some((owner_id.def_id, *body)),
5033
5034 Node::Item(Item {
5035 owner_id, kind: ItemKind::GlobalAsm { asm: _, fake_body }, ..
5036 }) => Some((owner_id.def_id, *fake_body)),
5037
5038 Node::Expr(Expr { kind: ExprKind::Closure(Closure { def_id, body, .. }), .. }) => {
5039 Some((*def_id, *body))
5040 }
5041
5042 Node::AnonConst(constant) => Some((constant.def_id, constant.body)),
5043 Node::ConstBlock(constant) => Some((constant.def_id, constant.body)),
5044
5045 _ => None,
5046 }
5047 }
5048
5049 pub fn body_id(&self) -> Option<BodyId> {
5050 Some(self.associated_body()?.1)
5051 }
5052
5053 pub fn generics(self) -> Option<&'hir Generics<'hir>> {
5054 match self {
5055 Node::ForeignItem(ForeignItem {
5056 kind: ForeignItemKind::Fn(_, _, generics), ..
5057 })
5058 | Node::TraitItem(TraitItem { generics, .. })
5059 | Node::ImplItem(ImplItem { generics, .. }) => Some(generics),
5060 Node::Item(item) => item.kind.generics(),
5061 _ => None,
5062 }
5063 }
5064
5065 pub fn as_owner(self) -> Option<OwnerNode<'hir>> {
5066 match self {
5067 Node::Item(i) => Some(OwnerNode::Item(i)),
5068 Node::ForeignItem(i) => Some(OwnerNode::ForeignItem(i)),
5069 Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
5070 Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
5071 Node::Crate(i) => Some(OwnerNode::Crate(i)),
5072 Node::Synthetic => Some(OwnerNode::Synthetic),
5073 _ => None,
5074 }
5075 }
5076
5077 pub fn fn_kind(self) -> Option<FnKind<'hir>> {
5078 match self {
5079 Node::Item(i) => match i.kind {
5080 ItemKind::Fn { ident, sig, generics, .. } => {
5081 Some(FnKind::ItemFn(ident, generics, sig.header))
5082 }
5083 _ => None,
5084 },
5085 Node::TraitItem(ti) => match ti.kind {
5086 TraitItemKind::Fn(ref sig, _) => Some(FnKind::Method(ti.ident, sig)),
5087 _ => None,
5088 },
5089 Node::ImplItem(ii) => match ii.kind {
5090 ImplItemKind::Fn(ref sig, _) => Some(FnKind::Method(ii.ident, sig)),
5091 _ => None,
5092 },
5093 Node::Expr(e) => match e.kind {
5094 ExprKind::Closure { .. } => Some(FnKind::Closure),
5095 _ => None,
5096 },
5097 _ => None,
5098 }
5099 }
5100
5101 self
let Node::Expr(Expr { kind: ExprKind::Closure(n), .. }) =
self else { expect_failed("expect_closure", self) };
n;expect_methods_self! {
5102 expect_param, &'hir Param<'hir>, Node::Param(n), n;
5103 expect_item, &'hir Item<'hir>, Node::Item(n), n;
5104 expect_foreign_item, &'hir ForeignItem<'hir>, Node::ForeignItem(n), n;
5105 expect_trait_item, &'hir TraitItem<'hir>, Node::TraitItem(n), n;
5106 expect_impl_item, &'hir ImplItem<'hir>, Node::ImplItem(n), n;
5107 expect_variant, &'hir Variant<'hir>, Node::Variant(n), n;
5108 expect_field, &'hir FieldDef<'hir>, Node::Field(n), n;
5109 expect_anon_const, &'hir AnonConst, Node::AnonConst(n), n;
5110 expect_inline_const, &'hir ConstBlock, Node::ConstBlock(n), n;
5111 expect_expr, &'hir Expr<'hir>, Node::Expr(n), n;
5112 expect_expr_field, &'hir ExprField<'hir>, Node::ExprField(n), n;
5113 expect_stmt, &'hir Stmt<'hir>, Node::Stmt(n), n;
5114 expect_path_segment, &'hir PathSegment<'hir>, Node::PathSegment(n), n;
5115 expect_ty, &'hir Ty<'hir>, Node::Ty(n), n;
5116 expect_assoc_item_constraint, &'hir AssocItemConstraint<'hir>, Node::AssocItemConstraint(n), n;
5117 expect_trait_ref, &'hir TraitRef<'hir>, Node::TraitRef(n), n;
5118 expect_opaque_ty, &'hir OpaqueTy<'hir>, Node::OpaqueTy(n), n;
5119 expect_pat, &'hir Pat<'hir>, Node::Pat(n), n;
5120 expect_pat_field, &'hir PatField<'hir>, Node::PatField(n), n;
5121 expect_arm, &'hir Arm<'hir>, Node::Arm(n), n;
5122 expect_block, &'hir Block<'hir>, Node::Block(n), n;
5123 expect_let_stmt, &'hir LetStmt<'hir>, Node::LetStmt(n), n;
5124 expect_ctor, &'hir VariantData<'hir>, Node::Ctor(n), n;
5125 expect_lifetime, &'hir Lifetime, Node::Lifetime(n), n;
5126 expect_generic_param, &'hir GenericParam<'hir>, Node::GenericParam(n), n;
5127 expect_crate, &'hir Mod<'hir>, Node::Crate(n), n;
5128 expect_infer, &'hir InferArg, Node::Infer(n), n;
5129 expect_closure, &'hir Closure<'hir>, Node::Expr(Expr { kind: ExprKind::Closure(n), .. }), n;
5130 }
5131}
5132
5133#[cfg(target_pointer_width = "64")]
5135mod size_asserts {
5136 use rustc_data_structures::static_assert_size;
5137
5138 use super::*;
5139 const _: [(); 48] = [(); ::std::mem::size_of::<Block<'_>>()];static_assert_size!(Block<'_>, 48);
5141 const _: [(); 24] = [(); ::std::mem::size_of::<Body<'_>>()];static_assert_size!(Body<'_>, 24);
5142 const _: [(); 64] = [(); ::std::mem::size_of::<Expr<'_>>()];static_assert_size!(Expr<'_>, 64);
5143 const _: [(); 48] = [(); ::std::mem::size_of::<ExprKind<'_>>()];static_assert_size!(ExprKind<'_>, 48);
5144 const _: [(); 40] = [(); ::std::mem::size_of::<FnDecl<'_>>()];static_assert_size!(FnDecl<'_>, 40);
5145 const _: [(); 96] = [(); ::std::mem::size_of::<ForeignItem<'_>>()];static_assert_size!(ForeignItem<'_>, 96);
5146 const _: [(); 56] = [(); ::std::mem::size_of::<ForeignItemKind<'_>>()];static_assert_size!(ForeignItemKind<'_>, 56);
5147 const _: [(); 16] = [(); ::std::mem::size_of::<GenericArg<'_>>()];static_assert_size!(GenericArg<'_>, 16);
5148 const _: [(); 64] = [(); ::std::mem::size_of::<GenericBound<'_>>()];static_assert_size!(GenericBound<'_>, 64);
5149 const _: [(); 56] = [(); ::std::mem::size_of::<Generics<'_>>()];static_assert_size!(Generics<'_>, 56);
5150 const _: [(); 48] = [(); ::std::mem::size_of::<Impl<'_>>()];static_assert_size!(Impl<'_>, 48);
5151 const _: [(); 88] = [(); ::std::mem::size_of::<ImplItem<'_>>()];static_assert_size!(ImplItem<'_>, 88);
5152 const _: [(); 40] = [(); ::std::mem::size_of::<ImplItemKind<'_>>()];static_assert_size!(ImplItemKind<'_>, 40);
5153 const _: [(); 88] = [(); ::std::mem::size_of::<Item<'_>>()];static_assert_size!(Item<'_>, 88);
5154 const _: [(); 64] = [(); ::std::mem::size_of::<ItemKind<'_>>()];static_assert_size!(ItemKind<'_>, 64);
5155 const _: [(); 64] = [(); ::std::mem::size_of::<LetStmt<'_>>()];static_assert_size!(LetStmt<'_>, 64);
5156 const _: [(); 32] = [(); ::std::mem::size_of::<Param<'_>>()];static_assert_size!(Param<'_>, 32);
5157 const _: [(); 80] = [(); ::std::mem::size_of::<Pat<'_>>()];static_assert_size!(Pat<'_>, 80);
5158 const _: [(); 56] = [(); ::std::mem::size_of::<PatKind<'_>>()];static_assert_size!(PatKind<'_>, 56);
5159 const _: [(); 40] = [(); ::std::mem::size_of::<Path<'_>>()];static_assert_size!(Path<'_>, 40);
5160 const _: [(); 48] = [(); ::std::mem::size_of::<PathSegment<'_>>()];static_assert_size!(PathSegment<'_>, 48);
5161 const _: [(); 24] = [(); ::std::mem::size_of::<QPath<'_>>()];static_assert_size!(QPath<'_>, 24);
5162 const _: [(); 12] = [(); ::std::mem::size_of::<Res>()];static_assert_size!(Res, 12);
5163 const _: [(); 32] = [(); ::std::mem::size_of::<Stmt<'_>>()];static_assert_size!(Stmt<'_>, 32);
5164 const _: [(); 16] = [(); ::std::mem::size_of::<StmtKind<'_>>()];static_assert_size!(StmtKind<'_>, 16);
5165 const _: [(); 48] = [(); ::std::mem::size_of::<TraitImplHeader<'_>>()];static_assert_size!(TraitImplHeader<'_>, 48);
5166 const _: [(); 88] = [(); ::std::mem::size_of::<TraitItem<'_>>()];static_assert_size!(TraitItem<'_>, 88);
5167 const _: [(); 48] = [(); ::std::mem::size_of::<TraitItemKind<'_>>()];static_assert_size!(TraitItemKind<'_>, 48);
5168 const _: [(); 48] = [(); ::std::mem::size_of::<Ty<'_>>()];static_assert_size!(Ty<'_>, 48);
5169 const _: [(); 32] = [(); ::std::mem::size_of::<TyKind<'_>>()];static_assert_size!(TyKind<'_>, 32);
5170 }
5172
5173#[cfg(test)]
5174mod tests;