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: ::rustc_span::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: ::rustc_span::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: ::rustc_span::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: ::rustc_span::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: ::rustc_span::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: ::rustc_span::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: ::rustc_span::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: ::rustc_span::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 { args } else { GenericArgs::NONE }
401 }
402}
403
404#[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: ::rustc_span::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)]
405pub enum ConstItemRhs<'hir> {
406 Body(BodyId),
407 TypeConst(&'hir ConstArg<'hir>),
408}
409
410impl<'hir> ConstItemRhs<'hir> {
411 pub fn hir_id(&self) -> HirId {
412 match self {
413 ConstItemRhs::Body(body_id) => body_id.hir_id,
414 ConstItemRhs::TypeConst(ct_arg) => ct_arg.hir_id,
415 }
416 }
417
418 pub fn span<'tcx>(&self, tcx: impl crate::intravisit::HirTyCtxt<'tcx>) -> Span {
419 match self {
420 ConstItemRhs::Body(body_id) => tcx.hir_body(*body_id).value.span,
421 ConstItemRhs::TypeConst(ct_arg) => ct_arg.span,
422 }
423 }
424}
425
426#[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: ::rustc_span::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)]
440#[repr(C)]
441pub struct ConstArg<'hir, Unambig = ()> {
442 #[stable_hasher(ignore)]
443 pub hir_id: HirId,
444 pub kind: ConstArgKind<'hir, Unambig>,
445 pub span: Span,
446}
447
448impl<'hir> ConstArg<'hir, AmbigArg> {
449 pub fn as_unambig_ct(&self) -> &ConstArg<'hir> {
460 let ptr = self as *const ConstArg<'hir, AmbigArg> as *const ConstArg<'hir, ()>;
463 unsafe { &*ptr }
464 }
465}
466
467impl<'hir> ConstArg<'hir> {
468 pub fn try_as_ambig_ct(&self) -> Option<&ConstArg<'hir, AmbigArg>> {
474 if let ConstArgKind::Infer(()) = self.kind {
475 return None;
476 }
477
478 let ptr = self as *const ConstArg<'hir> as *const ConstArg<'hir, AmbigArg>;
482 Some(unsafe { &*ptr })
483 }
484}
485
486impl<'hir, Unambig> ConstArg<'hir, Unambig> {
487 pub fn anon_const_hir_id(&self) -> Option<HirId> {
488 match self.kind {
489 ConstArgKind::Anon(ac) => Some(ac.hir_id),
490 _ => None,
491 }
492 }
493}
494
495#[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: ::rustc_span::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)]
497#[repr(u8, C)]
498pub enum ConstArgKind<'hir, Unambig = ()> {
499 Tup(&'hir [&'hir ConstArg<'hir, Unambig>]),
500 Path(QPath<'hir>),
506 Anon(&'hir AnonConst),
507 Struct(QPath<'hir>, &'hir [&'hir ConstArgExprField<'hir>]),
509 TupleCall(QPath<'hir>, &'hir [&'hir ConstArg<'hir>]),
511 Array(&'hir ConstArgArrayExpr<'hir>),
513 Error(ErrorGuaranteed),
515 Infer(Unambig),
518 Literal {
519 lit: LitKind,
520 negated: bool,
521 },
522}
523
524#[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: ::rustc_span::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)]
525pub struct ConstArgExprField<'hir> {
526 pub hir_id: HirId,
527 pub span: Span,
528 pub field: Ident,
529 pub expr: &'hir ConstArg<'hir>,
530}
531
532#[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: ::rustc_span::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)]
533pub struct ConstArgArrayExpr<'hir> {
534 pub span: Span,
535 pub elems: &'hir [&'hir ConstArg<'hir>],
536}
537
538#[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: ::rustc_span::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)]
539pub struct InferArg {
540 #[stable_hasher(ignore)]
541 pub hir_id: HirId,
542 pub span: Span,
543}
544
545impl InferArg {
546 pub fn to_ty(&self) -> Ty<'static> {
547 Ty { kind: TyKind::Infer(()), span: self.span, hir_id: self.hir_id }
548 }
549}
550
551#[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: ::rustc_span::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)]
552pub enum GenericArg<'hir> {
553 Lifetime(&'hir Lifetime),
554 Type(&'hir Ty<'hir, AmbigArg>),
555 Const(&'hir ConstArg<'hir, AmbigArg>),
556 Infer(InferArg),
566}
567
568impl GenericArg<'_> {
569 pub fn span(&self) -> Span {
570 match self {
571 GenericArg::Lifetime(l) => l.ident.span,
572 GenericArg::Type(t) => t.span,
573 GenericArg::Const(c) => c.span,
574 GenericArg::Infer(i) => i.span,
575 }
576 }
577
578 pub fn hir_id(&self) -> HirId {
579 match self {
580 GenericArg::Lifetime(l) => l.hir_id,
581 GenericArg::Type(t) => t.hir_id,
582 GenericArg::Const(c) => c.hir_id,
583 GenericArg::Infer(i) => i.hir_id,
584 }
585 }
586
587 pub fn descr(&self) -> &'static str {
588 match self {
589 GenericArg::Lifetime(_) => "lifetime",
590 GenericArg::Type(_) => "type",
591 GenericArg::Const(_) => "constant",
592 GenericArg::Infer(_) => "placeholder",
593 }
594 }
595
596 pub fn to_ord(&self) -> ast::ParamKindOrd {
597 match self {
598 GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime,
599 GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => {
600 ast::ParamKindOrd::TypeOrConst
601 }
602 }
603 }
604
605 pub fn is_ty_or_const(&self) -> bool {
606 match self {
607 GenericArg::Lifetime(_) => false,
608 GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => true,
609 }
610 }
611}
612
613#[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: ::rustc_span::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)]
615pub struct GenericArgs<'hir> {
616 pub args: &'hir [GenericArg<'hir>],
618 pub constraints: &'hir [AssocItemConstraint<'hir>],
620 pub parenthesized: GenericArgsParentheses,
625 pub span_ext: Span,
638}
639
640impl<'hir> GenericArgs<'hir> {
641 pub const NONE: &'hir GenericArgs<'hir> = &GenericArgs {
642 args: &[],
643 constraints: &[],
644 parenthesized: GenericArgsParentheses::No,
645 span_ext: DUMMY_SP,
646 };
647
648 pub fn paren_sugar_inputs_output(&self) -> Option<(&[Ty<'hir>], &Ty<'hir>)> {
653 if self.parenthesized != GenericArgsParentheses::ParenSugar {
654 return None;
655 }
656
657 let inputs = self
658 .args
659 .iter()
660 .find_map(|arg| {
661 let GenericArg::Type(ty) = arg else { return None };
662 let TyKind::Tup(tys) = &ty.kind else { return None };
663 Some(tys)
664 })
665 .unwrap();
666
667 Some((inputs, self.paren_sugar_output_inner()))
668 }
669
670 pub fn paren_sugar_output(&self) -> Option<&Ty<'hir>> {
675 (self.parenthesized == GenericArgsParentheses::ParenSugar)
676 .then(|| self.paren_sugar_output_inner())
677 }
678
679 fn paren_sugar_output_inner(&self) -> &Ty<'hir> {
680 let [constraint] = self.constraints.try_into().unwrap();
681 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);
682 constraint.ty().unwrap()
683 }
684
685 pub fn has_err(&self) -> Option<ErrorGuaranteed> {
686 self.args
687 .iter()
688 .find_map(|arg| {
689 let GenericArg::Type(ty) = arg else { return None };
690 let TyKind::Err(guar) = ty.kind else { return None };
691 Some(guar)
692 })
693 .or_else(|| {
694 self.constraints.iter().find_map(|constraint| {
695 let TyKind::Err(guar) = constraint.ty()?.kind else { return None };
696 Some(guar)
697 })
698 })
699 }
700
701 #[inline]
702 pub fn num_lifetime_params(&self) -> usize {
703 self.args.iter().filter(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
704 }
705
706 #[inline]
707 pub fn has_lifetime_params(&self) -> bool {
708 self.args.iter().any(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_)))
709 }
710
711 #[inline]
712 pub fn num_generic_params(&self) -> usize {
715 self.args.iter().filter(|arg| !#[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
716 }
717
718 pub fn span(&self) -> Option<Span> {
724 let span_ext = self.span_ext()?;
725 Some(span_ext.with_lo(span_ext.lo() + BytePos(1)).with_hi(span_ext.hi() - BytePos(1)))
726 }
727
728 pub fn span_ext(&self) -> Option<Span> {
730 Some(self.span_ext).filter(|span| !span.is_empty())
731 }
732
733 pub fn is_empty(&self) -> bool {
734 self.args.is_empty()
735 }
736}
737
738#[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: ::rustc_span::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)]
739pub enum GenericArgsParentheses {
740 No,
741 ReturnTypeNotation,
744 ParenSugar,
746}
747
748#[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: ::rustc_span::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)]
750pub struct TraitBoundModifiers {
751 pub constness: BoundConstness,
752 pub polarity: BoundPolarity,
753}
754
755impl TraitBoundModifiers {
756 pub const NONE: Self =
757 TraitBoundModifiers { constness: BoundConstness::Never, polarity: BoundPolarity::Positive };
758}
759
760#[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: ::rustc_span::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)]
761pub enum GenericBound<'hir> {
762 Trait(PolyTraitRef<'hir>),
763 Outlives(&'hir Lifetime),
764 Use(&'hir [PreciseCapturingArg<'hir>], Span),
765}
766
767impl GenericBound<'_> {
768 pub fn trait_ref(&self) -> Option<&TraitRef<'_>> {
769 match self {
770 GenericBound::Trait(data) => Some(&data.trait_ref),
771 _ => None,
772 }
773 }
774
775 pub fn span(&self) -> Span {
776 match self {
777 GenericBound::Trait(t, ..) => t.span,
778 GenericBound::Outlives(l) => l.ident.span,
779 GenericBound::Use(_, span) => *span,
780 }
781 }
782}
783
784pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>];
785
786#[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: ::rustc_span::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)]
787pub enum MissingLifetimeKind {
788 Underscore,
790 Ampersand,
792 Comma,
794 Brackets,
796}
797
798#[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: ::rustc_span::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)]
799pub enum LifetimeParamKind {
800 Explicit,
803
804 Elided(MissingLifetimeKind),
807
808 Error,
810}
811
812#[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: ::rustc_span::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)]
813pub enum GenericParamKind<'hir> {
814 Lifetime {
816 kind: LifetimeParamKind,
817 },
818 Type {
819 default: Option<&'hir Ty<'hir>>,
820 synthetic: bool,
821 },
822 Const {
823 ty: &'hir Ty<'hir>,
824 default: Option<&'hir ConstArg<'hir>>,
826 },
827}
828
829#[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: ::rustc_span::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)]
830pub struct GenericParam<'hir> {
831 #[stable_hasher(ignore)]
832 pub hir_id: HirId,
833 pub def_id: LocalDefId,
834 pub name: ParamName,
835 pub span: Span,
836 pub pure_wrt_drop: bool,
837 pub kind: GenericParamKind<'hir>,
838 pub colon_span: Option<Span>,
839 pub source: GenericParamSource,
840}
841
842impl<'hir> GenericParam<'hir> {
843 pub fn is_impl_trait(&self) -> bool {
847 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Type { synthetic: true, .. } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Type { synthetic: true, .. })
848 }
849
850 pub fn is_elided_lifetime(&self) -> bool {
854 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) })
855 }
856
857 pub fn is_lifetime(&self) -> bool {
858 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Lifetime { .. } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Lifetime { .. })
859 }
860}
861
862#[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: ::rustc_span::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)]
869pub enum GenericParamSource {
870 Generics,
872 Binder,
874}
875
876#[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)]
877pub struct GenericParamCount {
878 pub lifetimes: usize,
879 pub types: usize,
880 pub consts: usize,
881 pub infer: usize,
882}
883
884#[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: ::rustc_span::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)]
887pub struct Generics<'hir> {
888 pub params: &'hir [GenericParam<'hir>],
889 pub predicates: &'hir [WherePredicate<'hir>],
890 pub has_where_clause_predicates: bool,
891 pub where_clause_span: Span,
892 pub span: Span,
893}
894
895impl<'hir> Generics<'hir> {
896 pub const fn empty() -> &'hir Generics<'hir> {
897 const NOPE: Generics<'_> = Generics {
898 params: &[],
899 predicates: &[],
900 has_where_clause_predicates: false,
901 where_clause_span: DUMMY_SP,
902 span: DUMMY_SP,
903 };
904 &NOPE
905 }
906
907 pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'hir>> {
908 self.params.iter().find(|¶m| name == param.name.ident().name)
909 }
910
911 pub fn span_for_lifetime_suggestion(&self) -> Option<Span> {
913 if let Some(first) = self.params.first()
914 && self.span.contains(first.span)
915 {
916 Some(first.span.shrink_to_lo())
919 } else {
920 None
921 }
922 }
923
924 pub fn span_for_param_suggestion(&self) -> Option<Span> {
926 self.params.iter().any(|p| self.span.contains(p.span)).then(|| {
927 self.span.with_lo(self.span.hi() - BytePos(1)).shrink_to_lo()
930 })
931 }
932
933 pub fn tail_span_for_predicate_suggestion(&self) -> Span {
936 let end = self.where_clause_span.shrink_to_hi();
937 if self.has_where_clause_predicates {
938 self.predicates
939 .iter()
940 .rfind(|&p| p.kind.in_where_clause())
941 .map_or(end, |p| p.span)
942 .shrink_to_hi()
943 .to(end)
944 } else {
945 end
946 }
947 }
948
949 pub fn add_where_or_trailing_comma(&self) -> &'static str {
950 if self.has_where_clause_predicates {
951 ","
952 } else if self.where_clause_span.is_empty() {
953 " where"
954 } else {
955 ""
957 }
958 }
959
960 pub fn bounds_for_param(
961 &self,
962 param_def_id: LocalDefId,
963 ) -> impl Iterator<Item = &WhereBoundPredicate<'hir>> {
964 self.predicates.iter().filter_map(move |pred| match pred.kind {
965 WherePredicateKind::BoundPredicate(bp)
966 if bp.is_param_bound(param_def_id.to_def_id()) =>
967 {
968 Some(bp)
969 }
970 _ => None,
971 })
972 }
973
974 pub fn outlives_for_param(
975 &self,
976 param_def_id: LocalDefId,
977 ) -> impl Iterator<Item = &WhereRegionPredicate<'_>> {
978 self.predicates.iter().filter_map(move |pred| match pred.kind {
979 WherePredicateKind::RegionPredicate(rp) if rp.is_param_bound(param_def_id) => Some(rp),
980 _ => None,
981 })
982 }
983
984 pub fn bounds_span_for_suggestions(
995 &self,
996 param_def_id: LocalDefId,
997 ) -> Option<(Span, Option<Span>)> {
998 self.bounds_for_param(param_def_id).flat_map(|bp| bp.bounds.iter().rev()).find_map(
999 |bound| {
1000 let span_for_parentheses = if let Some(trait_ref) = bound.trait_ref()
1001 && let [.., segment] = trait_ref.path.segments
1002 && let Some(ret_ty) = segment.args().paren_sugar_output()
1003 && let ret_ty = ret_ty.peel_refs()
1004 && let TyKind::TraitObject(_, tagged_ptr) = ret_ty.kind
1005 && let TraitObjectSyntax::Dyn = tagged_ptr.tag()
1006 && ret_ty.span.can_be_used_for_suggestions()
1007 {
1008 Some(ret_ty.span)
1009 } else {
1010 None
1011 };
1012
1013 span_for_parentheses.map_or_else(
1014 || {
1015 let bs = bound.span();
1018 bs.from_expansion().not().then(|| (bs.shrink_to_hi(), None))
1023 },
1024 |span| Some((span.shrink_to_hi(), Some(span.shrink_to_lo()))),
1025 )
1026 },
1027 )
1028 }
1029
1030 pub fn span_for_predicate_removal(&self, pos: usize) -> Span {
1031 let predicate = &self.predicates[pos];
1032 let span = predicate.span;
1033
1034 if !predicate.kind.in_where_clause() {
1035 return span;
1038 }
1039
1040 if pos < self.predicates.len() - 1 {
1042 let next_pred = &self.predicates[pos + 1];
1043 if next_pred.kind.in_where_clause() {
1044 return span.until(next_pred.span);
1047 }
1048 }
1049
1050 if pos > 0 {
1051 let prev_pred = &self.predicates[pos - 1];
1052 if prev_pred.kind.in_where_clause() {
1053 return prev_pred.span.shrink_to_hi().to(span);
1056 }
1057 }
1058
1059 self.where_clause_span
1063 }
1064
1065 pub fn span_for_bound_removal(&self, predicate_pos: usize, bound_pos: usize) -> Span {
1066 let predicate = &self.predicates[predicate_pos];
1067 let bounds = predicate.kind.bounds();
1068
1069 if bounds.len() == 1 {
1070 return self.span_for_predicate_removal(predicate_pos);
1071 }
1072
1073 let bound_span = bounds[bound_pos].span();
1074 if bound_pos < bounds.len() - 1 {
1075 bound_span.to(bounds[bound_pos + 1].span().shrink_to_lo())
1081 } else {
1082 bound_span.with_lo(bounds[bound_pos - 1].span().hi())
1088 }
1089 }
1090}
1091
1092#[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: ::rustc_span::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)]
1094pub struct WherePredicate<'hir> {
1095 #[stable_hasher(ignore)]
1096 pub hir_id: HirId,
1097 pub span: Span,
1098 pub kind: &'hir WherePredicateKind<'hir>,
1099}
1100
1101#[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: ::rustc_span::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)]
1103pub enum WherePredicateKind<'hir> {
1104 BoundPredicate(WhereBoundPredicate<'hir>),
1106 RegionPredicate(WhereRegionPredicate<'hir>),
1108 EqPredicate(WhereEqPredicate<'hir>),
1110}
1111
1112impl<'hir> WherePredicateKind<'hir> {
1113 pub fn in_where_clause(&self) -> bool {
1114 match self {
1115 WherePredicateKind::BoundPredicate(p) => p.origin == PredicateOrigin::WhereClause,
1116 WherePredicateKind::RegionPredicate(p) => p.in_where_clause,
1117 WherePredicateKind::EqPredicate(_) => false,
1118 }
1119 }
1120
1121 pub fn bounds(&self) -> GenericBounds<'hir> {
1122 match self {
1123 WherePredicateKind::BoundPredicate(p) => p.bounds,
1124 WherePredicateKind::RegionPredicate(p) => p.bounds,
1125 WherePredicateKind::EqPredicate(_) => &[],
1126 }
1127 }
1128}
1129
1130#[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: ::rustc_span::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)]
1131pub enum PredicateOrigin {
1132 WhereClause,
1133 GenericParam,
1134 ImplTrait,
1135}
1136
1137#[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: ::rustc_span::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)]
1139pub struct WhereBoundPredicate<'hir> {
1140 pub origin: PredicateOrigin,
1142 pub bound_generic_params: &'hir [GenericParam<'hir>],
1144 pub bounded_ty: &'hir Ty<'hir>,
1146 pub bounds: GenericBounds<'hir>,
1148}
1149
1150impl<'hir> WhereBoundPredicate<'hir> {
1151 pub fn is_param_bound(&self, param_def_id: DefId) -> bool {
1153 self.bounded_ty.as_generic_param().is_some_and(|(def_id, _)| def_id == param_def_id)
1154 }
1155}
1156
1157#[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: ::rustc_span::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)]
1159pub struct WhereRegionPredicate<'hir> {
1160 pub in_where_clause: bool,
1161 pub lifetime: &'hir Lifetime,
1162 pub bounds: GenericBounds<'hir>,
1163}
1164
1165impl<'hir> WhereRegionPredicate<'hir> {
1166 fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
1168 self.lifetime.kind == LifetimeKind::Param(param_def_id)
1169 }
1170}
1171
1172#[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: ::rustc_span::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)]
1174pub struct WhereEqPredicate<'hir> {
1175 pub lhs_ty: &'hir Ty<'hir>,
1176 pub rhs_ty: &'hir Ty<'hir>,
1177}
1178
1179#[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)]
1183pub struct ParentedNode<'tcx> {
1184 pub parent: ItemLocalId,
1185 pub node: Node<'tcx>,
1186}
1187
1188#[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: ::rustc_span::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)]
1190pub enum AttrArgs {
1191 Empty,
1193 Delimited(DelimArgs),
1195 Eq {
1197 eq_span: Span,
1199 expr: MetaItemLit,
1201 },
1202}
1203
1204#[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: ::rustc_span::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)]
1205pub struct AttrPath {
1206 pub segments: Box<[Symbol]>,
1207 pub span: Span,
1208}
1209
1210impl IntoDiagArg for AttrPath {
1211 fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>) -> DiagArgValue {
1212 self.to_string().into_diag_arg(path)
1213 }
1214}
1215
1216impl AttrPath {
1217 pub fn from_ast(path: &ast::Path, lower_span: impl Copy + Fn(Span) -> Span) -> Self {
1218 AttrPath {
1219 segments: path
1220 .segments
1221 .iter()
1222 .map(|i| i.ident.name)
1223 .collect::<Vec<_>>()
1224 .into_boxed_slice(),
1225 span: lower_span(path.span),
1226 }
1227 }
1228}
1229
1230impl fmt::Display for AttrPath {
1231 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1232 f.write_fmt(format_args!("{0}",
join_path_idents(self.segments.iter().map(|i|
Ident { name: *i, span: DUMMY_SP }))))write!(
1233 f,
1234 "{}",
1235 join_path_idents(self.segments.iter().map(|i| Ident { name: *i, span: DUMMY_SP }))
1236 )
1237 }
1238}
1239
1240#[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: ::rustc_span::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)]
1241pub struct AttrItem {
1242 pub path: AttrPath,
1244 pub args: AttrArgs,
1245 pub id: HashIgnoredAttrId,
1246 pub style: AttrStyle,
1249 pub span: Span,
1251}
1252
1253#[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)]
1256pub struct HashIgnoredAttrId {
1257 pub attr_id: AttrId,
1258}
1259
1260#[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: ::rustc_span::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)]
1263pub enum Attribute {
1264 Parsed(AttributeKind),
1270
1271 Unparsed(Box<AttrItem>),
1274}
1275
1276impl Attribute {
1277 pub fn get_normal_item(&self) -> &AttrItem {
1278 match &self {
1279 Attribute::Unparsed(normal) => &normal,
1280 _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1281 }
1282 }
1283
1284 pub fn unwrap_normal_item(self) -> AttrItem {
1285 match self {
1286 Attribute::Unparsed(normal) => *normal,
1287 _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1288 }
1289 }
1290
1291 pub fn value_lit(&self) -> Option<&MetaItemLit> {
1292 match &self {
1293 Attribute::Unparsed(n) => match n.as_ref() {
1294 AttrItem { args: AttrArgs::Eq { eq_span: _, expr }, .. } => Some(expr),
1295 _ => None,
1296 },
1297 _ => None,
1298 }
1299 }
1300
1301 pub fn is_parsed_attr(&self) -> bool {
1302 match self {
1303 Attribute::Parsed(_) => true,
1304 Attribute::Unparsed(_) => false,
1305 }
1306 }
1307
1308 pub fn has_span_without_desugaring_kind(&self) -> bool {
1309 let span = match self {
1310 Attribute::Unparsed(attr) => attr.span,
1311 Attribute::Parsed(AttributeKind::Deprecated { span, .. }) => *span,
1312 Attribute::Parsed(AttributeKind::LintAttributes(sub_attrs)) => {
1313 return sub_attrs.iter().any(|attr| attr.attr_span.desugaring_kind().is_none());
1314 }
1315 Attribute::Parsed(attr) => {
::core::panicking::panic_fmt(format_args!("can\'t get span of parsed attr: {0:?}",
attr));
}panic!("can't get span of parsed attr: {:?}", attr),
1316 };
1317
1318 span.desugaring_kind().is_none()
1319 }
1320}
1321
1322impl AttributeExt for Attribute {
1323 #[inline]
1324 fn id(&self) -> AttrId {
1325 match &self {
1326 Attribute::Unparsed(u) => u.id.attr_id,
1327 _ => ::core::panicking::panic("explicit panic")panic!(),
1328 }
1329 }
1330
1331 #[inline]
1332 fn meta_item_list(&self) -> Option<ThinVec<ast::MetaItemInner>> {
1333 match &self {
1334 Attribute::Unparsed(n) => match n.as_ref() {
1335 AttrItem { args: AttrArgs::Delimited(d), .. } => {
1336 ast::MetaItemKind::list_from_tokens(d.tokens.clone())
1337 }
1338 _ => None,
1339 },
1340 _ => None,
1341 }
1342 }
1343
1344 #[inline]
1345 fn value_str(&self) -> Option<Symbol> {
1346 self.value_lit().and_then(|x| x.value_str())
1347 }
1348
1349 #[inline]
1350 fn value_span(&self) -> Option<Span> {
1351 self.value_lit().map(|i| i.span)
1352 }
1353
1354 #[inline]
1356 fn name(&self) -> Option<Symbol> {
1357 match &self {
1358 Attribute::Unparsed(n) => {
1359 if let [ident] = n.path.segments.as_ref() {
1360 Some(*ident)
1361 } else {
1362 None
1363 }
1364 }
1365 _ => None,
1366 }
1367 }
1368
1369 #[inline]
1370 fn path_matches(&self, name: &[Symbol]) -> bool {
1371 match &self {
1372 Attribute::Unparsed(n) => n.path.segments.iter().eq(name),
1373 _ => false,
1374 }
1375 }
1376
1377 #[inline]
1378 fn is_doc_comment(&self) -> Option<Span> {
1379 if let Attribute::Parsed(AttributeKind::DocComment { span, .. }) = self {
1380 Some(*span)
1381 } else {
1382 None
1383 }
1384 }
1385
1386 #[inline]
1387 fn span(&self) -> Span {
1388 match &self {
1389 Attribute::Unparsed(u) => u.span,
1390 Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
1392 Attribute::Parsed(AttributeKind::Deprecated { span, .. }) => *span,
1393 Attribute::Parsed(AttributeKind::CfgTrace(cfgs)) => cfgs[0].1,
1394 Attribute::Parsed(AttributeKind::LintAttributes(sub_attrs)) => sub_attrs[0].attr_span,
1395 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:?}"),
1396 }
1397 }
1398
1399 #[inline]
1400 fn is_word(&self) -> bool {
1401 match &self {
1402 Attribute::Unparsed(n) => {
1403 #[allow(non_exhaustive_omitted_patterns)] match n.args {
AttrArgs::Empty => true,
_ => false,
}matches!(n.args, AttrArgs::Empty)
1404 }
1405 _ => false,
1406 }
1407 }
1408
1409 #[inline]
1410 fn symbol_path(&self) -> Option<SmallVec<[Symbol; 1]>> {
1411 match &self {
1412 Attribute::Unparsed(n) => Some(n.path.segments.iter().copied().collect()),
1413 _ => None,
1414 }
1415 }
1416
1417 fn path_span(&self) -> Option<Span> {
1418 match &self {
1419 Attribute::Unparsed(attr) => Some(attr.path.span),
1420 Attribute::Parsed(_) => None,
1421 }
1422 }
1423
1424 #[inline]
1425 fn doc_str(&self) -> Option<Symbol> {
1426 match &self {
1427 Attribute::Parsed(AttributeKind::DocComment { comment, .. }) => Some(*comment),
1428 _ => None,
1429 }
1430 }
1431
1432 #[inline]
1433 fn deprecation_note(&self) -> Option<Ident> {
1434 match &self {
1435 Attribute::Parsed(AttributeKind::Deprecated { deprecation, .. }) => deprecation.note,
1436 _ => None,
1437 }
1438 }
1439
1440 fn is_automatically_derived_attr(&self) -> bool {
1441 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)) => true,
_ => false,
}matches!(self, Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)))
1442 }
1443
1444 #[inline]
1445 fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1446 match &self {
1447 Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => {
1448 Some((*comment, *kind))
1449 }
1450 _ => None,
1451 }
1452 }
1453
1454 fn doc_resolution_scope(&self) -> Option<AttrStyle> {
1455 match self {
1456 Attribute::Parsed(AttributeKind::DocComment { style, .. }) => Some(*style),
1457 Attribute::Unparsed(attr) if self.has_name(sym::doc) && self.value_str().is_some() => {
1458 Some(attr.style)
1459 }
1460 _ => None,
1461 }
1462 }
1463
1464 fn is_proc_macro_attr(&self) -> bool {
1465 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::ProcMacro(..) |
AttributeKind::ProcMacroAttribute(..) |
AttributeKind::ProcMacroDerive { .. }) => true,
_ => false,
}matches!(
1466 self,
1467 Attribute::Parsed(
1468 AttributeKind::ProcMacro(..)
1469 | AttributeKind::ProcMacroAttribute(..)
1470 | AttributeKind::ProcMacroDerive { .. }
1471 )
1472 )
1473 }
1474
1475 fn is_doc_hidden(&self) -> bool {
1476 #[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())
1477 }
1478
1479 fn is_doc_keyword_or_attribute(&self) -> bool {
1480 #[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())
1481 }
1482
1483 fn is_rustc_doc_primitive(&self) -> bool {
1484 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::RustcDocPrimitive(..)) => true,
_ => false,
}matches!(self, Attribute::Parsed(AttributeKind::RustcDocPrimitive(..)))
1485 }
1486}
1487
1488impl Attribute {
1490 #[inline]
1491 pub fn id(&self) -> AttrId {
1492 AttributeExt::id(self)
1493 }
1494
1495 #[inline]
1496 pub fn name(&self) -> Option<Symbol> {
1497 AttributeExt::name(self)
1498 }
1499
1500 #[inline]
1501 pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
1502 AttributeExt::meta_item_list(self)
1503 }
1504
1505 #[inline]
1506 pub fn value_str(&self) -> Option<Symbol> {
1507 AttributeExt::value_str(self)
1508 }
1509
1510 #[inline]
1511 pub fn value_span(&self) -> Option<Span> {
1512 AttributeExt::value_span(self)
1513 }
1514
1515 #[inline]
1516 pub fn path_matches(&self, name: &[Symbol]) -> bool {
1517 AttributeExt::path_matches(self, name)
1518 }
1519
1520 #[inline]
1521 pub fn is_doc_comment(&self) -> Option<Span> {
1522 AttributeExt::is_doc_comment(self)
1523 }
1524
1525 #[inline]
1526 pub fn has_name(&self, name: Symbol) -> bool {
1527 AttributeExt::has_name(self, name)
1528 }
1529
1530 #[inline]
1531 pub fn has_any_name(&self, names: &[Symbol]) -> bool {
1532 AttributeExt::has_any_name(self, names)
1533 }
1534
1535 #[inline]
1536 pub fn span(&self) -> Span {
1537 AttributeExt::span(self)
1538 }
1539
1540 #[inline]
1541 pub fn is_word(&self) -> bool {
1542 AttributeExt::is_word(self)
1543 }
1544
1545 #[inline]
1546 pub fn path(&self) -> SmallVec<[Symbol; 1]> {
1547 AttributeExt::path(self)
1548 }
1549
1550 #[inline]
1551 pub fn doc_str(&self) -> Option<Symbol> {
1552 AttributeExt::doc_str(self)
1553 }
1554
1555 #[inline]
1556 pub fn is_proc_macro_attr(&self) -> bool {
1557 AttributeExt::is_proc_macro_attr(self)
1558 }
1559
1560 #[inline]
1561 pub fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1562 AttributeExt::doc_str_and_fragment_kind(self)
1563 }
1564}
1565
1566#[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)]
1568pub struct AttributeMap<'tcx> {
1569 pub map: SortedMap<ItemLocalId, &'tcx [Attribute]>,
1570 pub define_opaque: Option<&'tcx [(Span, LocalDefId)]>,
1572 pub opt_hash: Option<Fingerprint>,
1574}
1575
1576impl<'tcx> AttributeMap<'tcx> {
1577 pub const EMPTY: &'static AttributeMap<'static> = &AttributeMap {
1578 map: SortedMap::new(),
1579 opt_hash: Some(Fingerprint::ZERO),
1580 define_opaque: None,
1581 };
1582
1583 #[inline]
1584 pub fn get(&self, id: ItemLocalId) -> &'tcx [Attribute] {
1585 self.map.get(&id).copied().unwrap_or(&[])
1586 }
1587}
1588
1589pub struct OwnerNodes<'tcx> {
1593 pub opt_hash_including_bodies: Option<Fingerprint>,
1596 pub nodes: IndexVec<ItemLocalId, ParentedNode<'tcx>>,
1601 pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>,
1603}
1604
1605impl<'tcx> OwnerNodes<'tcx> {
1606 pub fn node(&self) -> OwnerNode<'tcx> {
1607 self.nodes[ItemLocalId::ZERO].node.as_owner().unwrap()
1609 }
1610}
1611
1612impl fmt::Debug for OwnerNodes<'_> {
1613 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1614 f.debug_struct("OwnerNodes")
1615 .field("node", &self.nodes[ItemLocalId::ZERO])
1617 .field(
1618 "parents",
1619 &fmt::from_fn(|f| {
1620 f.debug_list()
1621 .entries(self.nodes.iter_enumerated().map(|(id, parented_node)| {
1622 fmt::from_fn(move |f| f.write_fmt(format_args!("({1:?}, {0:?})", parented_node.parent, id))write!(f, "({id:?}, {:?})", parented_node.parent))
1623 }))
1624 .finish()
1625 }),
1626 )
1627 .field("bodies", &self.bodies)
1628 .field("opt_hash_including_bodies", &self.opt_hash_including_bodies)
1629 .finish()
1630 }
1631}
1632
1633#[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: ::rustc_span::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)]
1635pub struct OwnerInfo<'hir> {
1636 pub nodes: OwnerNodes<'hir>,
1638 pub parenting: LocalDefIdMap<ItemLocalId>,
1640 pub attrs: AttributeMap<'hir>,
1642 pub trait_map: ItemLocalMap<&'hir [TraitCandidate<'hir>]>,
1645
1646 pub delayed_lints: DelayedLints,
1649}
1650
1651impl<'tcx> OwnerInfo<'tcx> {
1652 #[inline]
1653 pub fn node(&self) -> OwnerNode<'tcx> {
1654 self.nodes.node()
1655 }
1656}
1657
1658#[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: ::rustc_span::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)]
1659pub enum MaybeOwner<'tcx> {
1660 Owner(&'tcx OwnerInfo<'tcx>),
1661 NonOwner(HirId),
1662 Phantom,
1664}
1665
1666impl<'tcx> MaybeOwner<'tcx> {
1667 pub fn as_owner(self) -> Option<&'tcx OwnerInfo<'tcx>> {
1668 match self {
1669 MaybeOwner::Owner(i) => Some(i),
1670 MaybeOwner::NonOwner(_) | MaybeOwner::Phantom => None,
1671 }
1672 }
1673
1674 pub fn unwrap(self) -> &'tcx OwnerInfo<'tcx> {
1675 self.as_owner().unwrap_or_else(|| { ::core::panicking::panic_fmt(format_args!("Not a HIR owner")); }panic!("Not a HIR owner"))
1676 }
1677}
1678
1679#[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: ::rustc_span::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)]
1680pub struct Closure<'hir> {
1681 pub def_id: LocalDefId,
1682 pub binder: ClosureBinder,
1683 pub constness: Constness,
1684 pub capture_clause: CaptureBy,
1685 pub bound_generic_params: &'hir [GenericParam<'hir>],
1686 pub fn_decl: &'hir FnDecl<'hir>,
1687 pub body: BodyId,
1688 pub fn_decl_span: Span,
1690 pub fn_arg_span: Option<Span>,
1692 pub kind: ClosureKind,
1693}
1694
1695#[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: ::rustc_span::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)]
1696pub enum ClosureKind {
1697 Closure,
1699 Coroutine(CoroutineKind),
1704 CoroutineClosure(CoroutineDesugaring),
1709}
1710
1711#[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: ::rustc_span::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)]
1715pub struct Block<'hir> {
1716 pub stmts: &'hir [Stmt<'hir>],
1718 pub expr: Option<&'hir Expr<'hir>>,
1721 #[stable_hasher(ignore)]
1722 pub hir_id: HirId,
1723 pub rules: BlockCheckMode,
1725 pub span: Span,
1727 pub targeted_by_break: bool,
1731}
1732
1733impl<'hir> Block<'hir> {
1734 pub fn innermost_block(&self) -> &Block<'hir> {
1735 let mut block = self;
1736 while let Some(Expr { kind: ExprKind::Block(inner_block, _), .. }) = block.expr {
1737 block = inner_block;
1738 }
1739 block
1740 }
1741}
1742
1743#[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: ::rustc_span::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)]
1744pub struct TyFieldPath {
1745 pub variant: Option<Ident>,
1746 pub field: Ident,
1747}
1748
1749#[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: ::rustc_span::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)]
1750pub struct TyPat<'hir> {
1751 #[stable_hasher(ignore)]
1752 pub hir_id: HirId,
1753 pub kind: TyPatKind<'hir>,
1754 pub span: Span,
1755}
1756
1757#[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: ::rustc_span::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)]
1758pub struct Pat<'hir> {
1759 #[stable_hasher(ignore)]
1760 pub hir_id: HirId,
1761 pub kind: PatKind<'hir>,
1762 pub span: Span,
1763 pub default_binding_modes: bool,
1766}
1767
1768impl<'hir> Pat<'hir> {
1769 fn walk_short_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) -> bool {
1770 if !it(self) {
1771 return false;
1772 }
1773
1774 use PatKind::*;
1775 match self.kind {
1776 Missing => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1777 Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => true,
1778 Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => {
1779 s.walk_short_(it)
1780 }
1781 Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
1782 TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().all(|p| p.walk_short_(it)),
1783 Slice(before, slice, after) => {
1784 before.iter().chain(slice).chain(after.iter()).all(|p| p.walk_short_(it))
1785 }
1786 }
1787 }
1788
1789 pub fn walk_short(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) -> bool {
1796 self.walk_short_(&mut it)
1797 }
1798
1799 fn walk_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) {
1800 if !it(self) {
1801 return;
1802 }
1803
1804 use PatKind::*;
1805 match self.kind {
1806 Missing | Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => {}
1807 Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_(it),
1808 Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
1809 TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
1810 Slice(before, slice, after) => {
1811 before.iter().chain(slice).chain(after.iter()).for_each(|p| p.walk_(it))
1812 }
1813 }
1814 }
1815
1816 pub fn walk(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) {
1820 self.walk_(&mut it)
1821 }
1822
1823 pub fn walk_always(&self, mut it: impl FnMut(&Pat<'_>)) {
1827 self.walk(|p| {
1828 it(p);
1829 true
1830 })
1831 }
1832
1833 pub fn is_never_pattern(&self) -> bool {
1835 let mut is_never_pattern = false;
1836 self.walk(|pat| match &pat.kind {
1837 PatKind::Never => {
1838 is_never_pattern = true;
1839 false
1840 }
1841 PatKind::Or(s) => {
1842 is_never_pattern = s.iter().all(|p| p.is_never_pattern());
1843 false
1844 }
1845 _ => true,
1846 });
1847 is_never_pattern
1848 }
1849
1850 pub fn is_guaranteed_to_constitute_read_for_never(&self) -> bool {
1859 match self.kind {
1860 PatKind::Wild => false,
1862
1863 PatKind::Guard(pat, _) => pat.is_guaranteed_to_constitute_read_for_never(),
1866
1867 PatKind::Or(subpats) => {
1876 subpats.iter().all(|pat| pat.is_guaranteed_to_constitute_read_for_never())
1877 }
1878
1879 PatKind::Never => true,
1881
1882 PatKind::Missing
1885 | PatKind::Binding(_, _, _, _)
1886 | PatKind::Struct(_, _, _)
1887 | PatKind::TupleStruct(_, _, _)
1888 | PatKind::Tuple(_, _)
1889 | PatKind::Box(_)
1890 | PatKind::Ref(_, _, _)
1891 | PatKind::Deref(_)
1892 | PatKind::Expr(_)
1893 | PatKind::Range(_, _, _)
1894 | PatKind::Slice(_, _, _)
1895 | PatKind::Err(_) => true,
1896 }
1897 }
1898}
1899
1900#[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: ::rustc_span::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)]
1906pub struct PatField<'hir> {
1907 #[stable_hasher(ignore)]
1908 pub hir_id: HirId,
1909 pub ident: Ident,
1911 pub pat: &'hir Pat<'hir>,
1913 pub is_shorthand: bool,
1914 pub span: Span,
1915}
1916
1917#[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: ::rustc_span::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)]
1918pub enum RangeEnd {
1919 Included,
1920 Excluded,
1921}
1922
1923impl fmt::Display for RangeEnd {
1924 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1925 f.write_str(match self {
1926 RangeEnd::Included => "..=",
1927 RangeEnd::Excluded => "..",
1928 })
1929 }
1930}
1931
1932#[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: ::rustc_span::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)]
1936pub struct DotDotPos(u32);
1937
1938impl DotDotPos {
1939 pub fn new(n: Option<usize>) -> Self {
1941 match n {
1942 Some(n) => {
1943 if !(n < u32::MAX as usize) {
::core::panicking::panic("assertion failed: n < u32::MAX as usize")
};assert!(n < u32::MAX as usize);
1944 Self(n as u32)
1945 }
1946 None => Self(u32::MAX),
1947 }
1948 }
1949
1950 pub fn as_opt_usize(&self) -> Option<usize> {
1951 if self.0 == u32::MAX { None } else { Some(self.0 as usize) }
1952 }
1953}
1954
1955impl fmt::Debug for DotDotPos {
1956 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1957 self.as_opt_usize().fmt(f)
1958 }
1959}
1960
1961#[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: ::rustc_span::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)]
1962pub struct PatExpr<'hir> {
1963 #[stable_hasher(ignore)]
1964 pub hir_id: HirId,
1965 pub span: Span,
1966 pub kind: PatExprKind<'hir>,
1967}
1968
1969#[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: ::rustc_span::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)]
1970pub enum PatExprKind<'hir> {
1971 Lit {
1972 lit: Lit,
1973 negated: bool,
1974 },
1975 Path(QPath<'hir>),
1977}
1978
1979#[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: ::rustc_span::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)]
1980pub enum TyPatKind<'hir> {
1981 Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>),
1983
1984 NotNull,
1986
1987 Or(&'hir [TyPat<'hir>]),
1989
1990 Err(ErrorGuaranteed),
1992}
1993
1994#[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: ::rustc_span::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)]
1995pub enum PatKind<'hir> {
1996 Missing,
1998
1999 Wild,
2001
2002 Binding(BindingMode, HirId, Ident, Option<&'hir Pat<'hir>>),
2013
2014 Struct(QPath<'hir>, &'hir [PatField<'hir>], Option<Span>),
2017
2018 TupleStruct(QPath<'hir>, &'hir [Pat<'hir>], DotDotPos),
2022
2023 Or(&'hir [Pat<'hir>]),
2026
2027 Never,
2029
2030 Tuple(&'hir [Pat<'hir>], DotDotPos),
2034
2035 Box(&'hir Pat<'hir>),
2037
2038 Deref(&'hir Pat<'hir>),
2040
2041 Ref(&'hir Pat<'hir>, Pinnedness, Mutability),
2043
2044 Expr(&'hir PatExpr<'hir>),
2046
2047 Guard(&'hir Pat<'hir>, &'hir Expr<'hir>),
2049
2050 Range(Option<&'hir PatExpr<'hir>>, Option<&'hir PatExpr<'hir>>, RangeEnd),
2052
2053 Slice(&'hir [Pat<'hir>], Option<&'hir Pat<'hir>>, &'hir [Pat<'hir>]),
2063
2064 Err(ErrorGuaranteed),
2066}
2067
2068#[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: ::rustc_span::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)]
2070pub struct Stmt<'hir> {
2071 #[stable_hasher(ignore)]
2072 pub hir_id: HirId,
2073 pub kind: StmtKind<'hir>,
2074 pub span: Span,
2075}
2076
2077#[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: ::rustc_span::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)]
2079pub enum StmtKind<'hir> {
2080 Let(&'hir LetStmt<'hir>),
2082
2083 Item(ItemId),
2085
2086 Expr(&'hir Expr<'hir>),
2088
2089 Semi(&'hir Expr<'hir>),
2091}
2092
2093#[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: ::rustc_span::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)]
2095pub struct LetStmt<'hir> {
2096 pub super_: Option<Span>,
2098 pub pat: &'hir Pat<'hir>,
2099 pub ty: Option<&'hir Ty<'hir>>,
2101 pub init: Option<&'hir Expr<'hir>>,
2103 pub els: Option<&'hir Block<'hir>>,
2105 #[stable_hasher(ignore)]
2106 pub hir_id: HirId,
2107 pub span: Span,
2108 pub source: LocalSource,
2112}
2113
2114#[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: ::rustc_span::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)]
2117pub struct Arm<'hir> {
2118 #[stable_hasher(ignore)]
2119 pub hir_id: HirId,
2120 pub span: Span,
2121 pub pat: &'hir Pat<'hir>,
2123 pub guard: Option<&'hir Expr<'hir>>,
2125 pub body: &'hir Expr<'hir>,
2127}
2128
2129#[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: ::rustc_span::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)]
2135pub struct LetExpr<'hir> {
2136 pub span: Span,
2137 pub pat: &'hir Pat<'hir>,
2138 pub ty: Option<&'hir Ty<'hir>>,
2139 pub init: &'hir Expr<'hir>,
2140 pub recovered: ast::Recovered,
2143}
2144
2145#[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: ::rustc_span::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)]
2146pub struct ExprField<'hir> {
2147 #[stable_hasher(ignore)]
2148 pub hir_id: HirId,
2149 pub ident: Ident,
2150 pub expr: &'hir Expr<'hir>,
2151 pub span: Span,
2152 pub is_shorthand: bool,
2153}
2154
2155#[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: ::rustc_span::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)]
2156pub enum BlockCheckMode {
2157 DefaultBlock,
2158 UnsafeBlock(UnsafeSource),
2159}
2160
2161#[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: ::rustc_span::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)]
2162pub enum UnsafeSource {
2163 CompilerGenerated,
2164 UserProvided,
2165}
2166
2167#[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: ::rustc_span::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)]
2168pub struct BodyId {
2169 pub hir_id: HirId,
2170}
2171
2172#[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: ::rustc_span::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)]
2194pub struct Body<'hir> {
2195 pub params: &'hir [Param<'hir>],
2196 pub value: &'hir Expr<'hir>,
2197}
2198
2199impl<'hir> Body<'hir> {
2200 pub fn id(&self) -> BodyId {
2201 BodyId { hir_id: self.value.hir_id }
2202 }
2203}
2204
2205#[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: ::rustc_span::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)]
2207pub enum CoroutineKind {
2208 Desugared(CoroutineDesugaring, CoroutineSource),
2210
2211 Coroutine(Movability),
2213}
2214
2215impl CoroutineKind {
2216 pub fn movability(self) -> Movability {
2217 match self {
2218 CoroutineKind::Desugared(CoroutineDesugaring::Async, _)
2219 | CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _) => Movability::Static,
2220 CoroutineKind::Desugared(CoroutineDesugaring::Gen, _) => Movability::Movable,
2221 CoroutineKind::Coroutine(mov) => mov,
2222 }
2223 }
2224
2225 pub fn is_fn_like(self) -> bool {
2226 #[allow(non_exhaustive_omitted_patterns)] match self {
CoroutineKind::Desugared(_, CoroutineSource::Fn) => true,
_ => false,
}matches!(self, CoroutineKind::Desugared(_, CoroutineSource::Fn))
2227 }
2228
2229 pub fn to_plural_string(&self) -> String {
2230 match self {
2231 CoroutineKind::Desugared(d, CoroutineSource::Fn) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}fn bodies", d))
})format!("{d:#}fn bodies"),
2232 CoroutineKind::Desugared(d, CoroutineSource::Block) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}blocks", d))
})format!("{d:#}blocks"),
2233 CoroutineKind::Desugared(d, CoroutineSource::Closure) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}closure bodies", d))
})format!("{d:#}closure bodies"),
2234 CoroutineKind::Coroutine(_) => "coroutines".to_string(),
2235 }
2236 }
2237}
2238
2239impl fmt::Display for CoroutineKind {
2240 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2241 match self {
2242 CoroutineKind::Desugared(d, k) => {
2243 d.fmt(f)?;
2244 k.fmt(f)
2245 }
2246 CoroutineKind::Coroutine(_) => f.write_str("coroutine"),
2247 }
2248 }
2249}
2250
2251#[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: ::rustc_span::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)]
2257pub enum CoroutineSource {
2258 Block,
2260
2261 Closure,
2263
2264 Fn,
2266}
2267
2268impl fmt::Display for CoroutineSource {
2269 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2270 match self {
2271 CoroutineSource::Block => "block",
2272 CoroutineSource::Closure => "closure body",
2273 CoroutineSource::Fn => "fn body",
2274 }
2275 .fmt(f)
2276 }
2277}
2278
2279#[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: ::rustc_span::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)]
2280pub enum CoroutineDesugaring {
2281 Async,
2283
2284 Gen,
2286
2287 AsyncGen,
2290}
2291
2292impl fmt::Display for CoroutineDesugaring {
2293 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2294 match self {
2295 CoroutineDesugaring::Async => {
2296 if f.alternate() {
2297 f.write_str("`async` ")?;
2298 } else {
2299 f.write_str("async ")?
2300 }
2301 }
2302 CoroutineDesugaring::Gen => {
2303 if f.alternate() {
2304 f.write_str("`gen` ")?;
2305 } else {
2306 f.write_str("gen ")?
2307 }
2308 }
2309 CoroutineDesugaring::AsyncGen => {
2310 if f.alternate() {
2311 f.write_str("`async gen` ")?;
2312 } else {
2313 f.write_str("async gen ")?
2314 }
2315 }
2316 }
2317
2318 Ok(())
2319 }
2320}
2321
2322#[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)]
2323pub enum BodyOwnerKind {
2324 Fn,
2326
2327 Closure,
2329
2330 Const { inline: bool },
2332
2333 Static(Mutability),
2335
2336 GlobalAsm,
2338}
2339
2340impl BodyOwnerKind {
2341 pub fn is_fn_or_closure(self) -> bool {
2342 match self {
2343 BodyOwnerKind::Fn | BodyOwnerKind::Closure => true,
2344 BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(_) | BodyOwnerKind::GlobalAsm => {
2345 false
2346 }
2347 }
2348 }
2349}
2350
2351#[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)]
2353pub enum ConstContext {
2354 ConstFn,
2356
2357 Static(Mutability),
2359
2360 Const { inline: bool },
2370}
2371
2372impl ConstContext {
2373 pub fn keyword_name(self) -> &'static str {
2377 match self {
2378 Self::Const { .. } => "const",
2379 Self::Static(Mutability::Not) => "static",
2380 Self::Static(Mutability::Mut) => "static mut",
2381 Self::ConstFn => "const fn",
2382 }
2383 }
2384}
2385
2386impl fmt::Display for ConstContext {
2389 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2390 match *self {
2391 Self::Const { .. } => f.write_fmt(format_args!("constant"))write!(f, "constant"),
2392 Self::Static(_) => f.write_fmt(format_args!("static"))write!(f, "static"),
2393 Self::ConstFn => f.write_fmt(format_args!("constant function"))write!(f, "constant function"),
2394 }
2395 }
2396}
2397
2398impl IntoDiagArg for ConstContext {
2399 fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
2400 DiagArgValue::Str(Cow::Borrowed(match self {
2401 ConstContext::ConstFn => "const_fn",
2402 ConstContext::Static(_) => "static",
2403 ConstContext::Const { .. } => "const",
2404 }))
2405 }
2406}
2407
2408pub type Lit = Spanned<LitKind>;
2410
2411#[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: ::rustc_span::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)]
2420pub struct AnonConst {
2421 #[stable_hasher(ignore)]
2422 pub hir_id: HirId,
2423 pub def_id: LocalDefId,
2424 pub body: BodyId,
2425 pub span: Span,
2426}
2427
2428#[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: ::rustc_span::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)]
2430pub struct ConstBlock {
2431 #[stable_hasher(ignore)]
2432 pub hir_id: HirId,
2433 pub def_id: LocalDefId,
2434 pub body: BodyId,
2435}
2436
2437#[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: ::rustc_span::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)]
2446pub struct Expr<'hir> {
2447 #[stable_hasher(ignore)]
2448 pub hir_id: HirId,
2449 pub kind: ExprKind<'hir>,
2450 pub span: Span,
2451}
2452
2453impl Expr<'_> {
2454 pub fn precedence(&self, has_attr: &dyn Fn(HirId) -> bool) -> ExprPrecedence {
2455 let prefix_attrs_precedence = || -> ExprPrecedence {
2456 if has_attr(self.hir_id) { ExprPrecedence::Prefix } else { ExprPrecedence::Unambiguous }
2457 };
2458
2459 match &self.kind {
2460 ExprKind::Closure(closure) => {
2461 match closure.fn_decl.output {
2462 FnRetTy::DefaultReturn(_) => ExprPrecedence::Jump,
2463 FnRetTy::Return(_) => prefix_attrs_precedence(),
2464 }
2465 }
2466
2467 ExprKind::Break(..)
2468 | ExprKind::Ret(..)
2469 | ExprKind::Yield(..)
2470 | ExprKind::Become(..) => ExprPrecedence::Jump,
2471
2472 ExprKind::Binary(op, ..) => op.node.precedence(),
2474 ExprKind::Cast(..) => ExprPrecedence::Cast,
2475
2476 ExprKind::Assign(..) |
2477 ExprKind::AssignOp(..) => ExprPrecedence::Assign,
2478
2479 ExprKind::AddrOf(..)
2481 | ExprKind::Let(..)
2486 | ExprKind::Unary(..) => ExprPrecedence::Prefix,
2487
2488 ExprKind::Array(_)
2490 | ExprKind::Block(..)
2491 | ExprKind::Call(..)
2492 | ExprKind::ConstBlock(_)
2493 | ExprKind::Continue(..)
2494 | ExprKind::Field(..)
2495 | ExprKind::If(..)
2496 | ExprKind::Index(..)
2497 | ExprKind::InlineAsm(..)
2498 | ExprKind::Lit(_)
2499 | ExprKind::Loop(..)
2500 | ExprKind::Match(..)
2501 | ExprKind::MethodCall(..)
2502 | ExprKind::OffsetOf(..)
2503 | ExprKind::Path(..)
2504 | ExprKind::Repeat(..)
2505 | ExprKind::Struct(..)
2506 | ExprKind::Tup(_)
2507 | ExprKind::Type(..)
2508 | ExprKind::UnsafeBinderCast(..)
2509 | ExprKind::Use(..)
2510 | ExprKind::Err(_) => prefix_attrs_precedence(),
2511
2512 ExprKind::DropTemps(expr, ..) => expr.precedence(has_attr),
2513 }
2514 }
2515
2516 pub fn is_syntactic_place_expr(&self) -> bool {
2521 self.is_place_expr(|_| true)
2522 }
2523
2524 pub fn is_place_expr(&self, mut allow_projections_from: impl FnMut(&Self) -> bool) -> bool {
2529 match self.kind {
2530 ExprKind::Path(QPath::Resolved(_, ref path)) => {
2531 #[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)
2532 }
2533
2534 ExprKind::Type(ref e, _) => e.is_place_expr(allow_projections_from),
2538
2539 ExprKind::UnsafeBinderCast(_, e, _) => e.is_place_expr(allow_projections_from),
2541
2542 ExprKind::Unary(UnOp::Deref, _) => true,
2543
2544 ExprKind::Field(ref base, _) | ExprKind::Index(ref base, _, _) => {
2545 allow_projections_from(base) || base.is_place_expr(allow_projections_from)
2546 }
2547
2548 ExprKind::Err(_guar)
2550 | ExprKind::Let(&LetExpr { recovered: ast::Recovered::Yes(_guar), .. }) => true,
2551
2552 ExprKind::Path(QPath::TypeRelative(..))
2555 | ExprKind::Call(..)
2556 | ExprKind::MethodCall(..)
2557 | ExprKind::Use(..)
2558 | ExprKind::Struct(..)
2559 | ExprKind::Tup(..)
2560 | ExprKind::If(..)
2561 | ExprKind::Match(..)
2562 | ExprKind::Closure { .. }
2563 | ExprKind::Block(..)
2564 | ExprKind::Repeat(..)
2565 | ExprKind::Array(..)
2566 | ExprKind::Break(..)
2567 | ExprKind::Continue(..)
2568 | ExprKind::Ret(..)
2569 | ExprKind::Become(..)
2570 | ExprKind::Let(..)
2571 | ExprKind::Loop(..)
2572 | ExprKind::Assign(..)
2573 | ExprKind::InlineAsm(..)
2574 | ExprKind::OffsetOf(..)
2575 | ExprKind::AssignOp(..)
2576 | ExprKind::Lit(_)
2577 | ExprKind::ConstBlock(..)
2578 | ExprKind::Unary(..)
2579 | ExprKind::AddrOf(..)
2580 | ExprKind::Binary(..)
2581 | ExprKind::Yield(..)
2582 | ExprKind::Cast(..)
2583 | ExprKind::DropTemps(..) => false,
2584 }
2585 }
2586
2587 pub fn range_span(&self) -> Option<Span> {
2590 is_range_literal(self).then(|| self.span.parent_callsite().unwrap())
2591 }
2592
2593 pub fn is_size_lit(&self) -> bool {
2596 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ExprKind::Lit(Lit {
node: LitKind::Int(_,
LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)), ..
}) => true,
_ => false,
}matches!(
2597 self.kind,
2598 ExprKind::Lit(Lit {
2599 node: LitKind::Int(_, LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)),
2600 ..
2601 })
2602 )
2603 }
2604
2605 pub fn peel_drop_temps(&self) -> &Self {
2611 let mut expr = self;
2612 while let ExprKind::DropTemps(inner) = &expr.kind {
2613 expr = inner;
2614 }
2615 expr
2616 }
2617
2618 pub fn peel_blocks(&self) -> &Self {
2619 let mut expr = self;
2620 while let ExprKind::Block(Block { expr: Some(inner), .. }, _) = &expr.kind {
2621 expr = inner;
2622 }
2623 expr
2624 }
2625
2626 pub fn peel_borrows(&self) -> &Self {
2627 let mut expr = self;
2628 while let ExprKind::AddrOf(.., inner) = &expr.kind {
2629 expr = inner;
2630 }
2631 expr
2632 }
2633
2634 pub fn can_have_side_effects(&self) -> bool {
2635 match self.peel_drop_temps().kind {
2636 ExprKind::Path(_) | ExprKind::Lit(_) | ExprKind::OffsetOf(..) | ExprKind::Use(..) => {
2637 false
2638 }
2639 ExprKind::Type(base, _)
2640 | ExprKind::Unary(_, base)
2641 | ExprKind::Field(base, _)
2642 | ExprKind::Index(base, _, _)
2643 | ExprKind::AddrOf(.., base)
2644 | ExprKind::Cast(base, _)
2645 | ExprKind::UnsafeBinderCast(_, base, _) => {
2646 base.can_have_side_effects()
2650 }
2651 ExprKind::Binary(_, lhs, rhs) => {
2652 lhs.can_have_side_effects() || rhs.can_have_side_effects()
2656 }
2657 ExprKind::Struct(_, fields, init) => {
2658 let init_side_effects = match init {
2659 StructTailExpr::Base(init) => init.can_have_side_effects(),
2660 StructTailExpr::DefaultFields(_)
2661 | StructTailExpr::None
2662 | StructTailExpr::NoneWithError(_) => false,
2663 };
2664 fields.iter().map(|field| field.expr).any(|e| e.can_have_side_effects())
2665 || init_side_effects
2666 }
2667
2668 ExprKind::Array(args)
2669 | ExprKind::Tup(args)
2670 | ExprKind::Call(
2671 Expr {
2672 kind:
2673 ExprKind::Path(QPath::Resolved(
2674 None,
2675 Path { res: Res::Def(DefKind::Ctor(_, CtorKind::Fn), _), .. },
2676 )),
2677 ..
2678 },
2679 args,
2680 ) => args.iter().any(|arg| arg.can_have_side_effects()),
2681 ExprKind::Repeat(arg, _) => arg.can_have_side_effects(),
2682 ExprKind::If(..)
2683 | ExprKind::Match(..)
2684 | ExprKind::MethodCall(..)
2685 | ExprKind::Call(..)
2686 | ExprKind::Closure { .. }
2687 | ExprKind::Block(..)
2688 | ExprKind::Break(..)
2689 | ExprKind::Continue(..)
2690 | ExprKind::Ret(..)
2691 | ExprKind::Become(..)
2692 | ExprKind::Let(..)
2693 | ExprKind::Loop(..)
2694 | ExprKind::Assign(..)
2695 | ExprKind::InlineAsm(..)
2696 | ExprKind::AssignOp(..)
2697 | ExprKind::ConstBlock(..)
2698 | ExprKind::Yield(..)
2699 | ExprKind::DropTemps(..)
2700 | ExprKind::Err(_) => true,
2701 }
2702 }
2703
2704 pub fn is_approximately_pattern(&self) -> bool {
2706 match &self.kind {
2707 ExprKind::Array(_)
2708 | ExprKind::Call(..)
2709 | ExprKind::Tup(_)
2710 | ExprKind::Lit(_)
2711 | ExprKind::Path(_)
2712 | ExprKind::Struct(..) => true,
2713 _ => false,
2714 }
2715 }
2716
2717 pub fn equivalent_for_indexing(&self, other: &Expr<'_>) -> bool {
2722 match (self.kind, other.kind) {
2723 (ExprKind::Lit(lit1), ExprKind::Lit(lit2)) => lit1.node == lit2.node,
2724 (
2725 ExprKind::Path(QPath::Resolved(None, path1)),
2726 ExprKind::Path(QPath::Resolved(None, path2)),
2727 ) => path1.res == path2.res,
2728 (
2729 ExprKind::Struct(
2730 &QPath::Resolved(None, &Path { res: Res::Def(_, path1_def_id), .. }),
2731 args1,
2732 StructTailExpr::None,
2733 ),
2734 ExprKind::Struct(
2735 &QPath::Resolved(None, &Path { res: Res::Def(_, path2_def_id), .. }),
2736 args2,
2737 StructTailExpr::None,
2738 ),
2739 ) => {
2740 path2_def_id == path1_def_id
2741 && is_range_literal(self)
2742 && is_range_literal(other)
2743 && std::iter::zip(args1, args2)
2744 .all(|(a, b)| a.expr.equivalent_for_indexing(b.expr))
2745 }
2746 _ => false,
2747 }
2748 }
2749
2750 pub fn method_ident(&self) -> Option<Ident> {
2751 match self.kind {
2752 ExprKind::MethodCall(receiver_method, ..) => Some(receiver_method.ident),
2753 ExprKind::Unary(_, expr) | ExprKind::AddrOf(.., expr) => expr.method_ident(),
2754 _ => None,
2755 }
2756 }
2757}
2758
2759pub fn is_range_literal(expr: &Expr<'_>) -> bool {
2762 if let ExprKind::Struct(QPath::Resolved(None, path), _, StructTailExpr::None) = expr.kind
2763 && let [.., segment] = path.segments
2764 && let sym::RangeFrom
2765 | sym::RangeFull
2766 | sym::Range
2767 | sym::RangeToInclusive
2768 | sym::RangeTo
2769 | sym::RangeFromCopy
2770 | sym::RangeCopy
2771 | sym::RangeInclusiveCopy
2772 | sym::RangeToInclusiveCopy = segment.ident.name
2773 && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2774 {
2775 true
2776 } else if let ExprKind::Call(func, _) = &expr.kind
2777 && let ExprKind::Path(QPath::Resolved(None, path)) = func.kind
2778 && let [.., segment] = path.segments
2779 && let sym::range_inclusive_new = segment.ident.name
2780 && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2781 {
2782 true
2783 } else {
2784 false
2785 }
2786}
2787
2788pub fn expr_needs_parens(expr: &Expr<'_>) -> bool {
2795 match expr.kind {
2796 ExprKind::Cast(_, _) | ExprKind::Binary(_, _, _) => true,
2798 _ if is_range_literal(expr) => true,
2800 _ => false,
2801 }
2802}
2803
2804#[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: ::rustc_span::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)]
2805pub enum ExprKind<'hir> {
2806 ConstBlock(ConstBlock),
2808 Array(&'hir [Expr<'hir>]),
2810 Call(&'hir Expr<'hir>, &'hir [Expr<'hir>]),
2817 MethodCall(&'hir PathSegment<'hir>, &'hir Expr<'hir>, &'hir [Expr<'hir>], Span),
2834 Use(&'hir Expr<'hir>, Span),
2836 Tup(&'hir [Expr<'hir>]),
2838 Binary(BinOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2840 Unary(UnOp, &'hir Expr<'hir>),
2842 Lit(Lit),
2844 Cast(&'hir Expr<'hir>, &'hir Ty<'hir>),
2846 Type(&'hir Expr<'hir>, &'hir Ty<'hir>),
2848 DropTemps(&'hir Expr<'hir>),
2854 Let(&'hir LetExpr<'hir>),
2859 If(&'hir Expr<'hir>, &'hir Expr<'hir>, Option<&'hir Expr<'hir>>),
2868 Loop(&'hir Block<'hir>, Option<Label>, LoopSource, Span),
2874 Match(&'hir Expr<'hir>, &'hir [Arm<'hir>], MatchSource),
2877 Closure(&'hir Closure<'hir>),
2884 Block(&'hir Block<'hir>, Option<Label>),
2886
2887 Assign(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
2889 AssignOp(AssignOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2893 Field(&'hir Expr<'hir>, Ident),
2895 Index(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
2899
2900 Path(QPath<'hir>),
2902
2903 AddrOf(BorrowKind, Mutability, &'hir Expr<'hir>),
2905 Break(Destination, Option<&'hir Expr<'hir>>),
2907 Continue(Destination),
2909 Ret(Option<&'hir Expr<'hir>>),
2911 Become(&'hir Expr<'hir>),
2913
2914 InlineAsm(&'hir InlineAsm<'hir>),
2916
2917 OffsetOf(&'hir Ty<'hir>, &'hir [Ident]),
2919
2920 Struct(&'hir QPath<'hir>, &'hir [ExprField<'hir>], StructTailExpr<'hir>),
2925
2926 Repeat(&'hir Expr<'hir>, &'hir ConstArg<'hir>),
2931
2932 Yield(&'hir Expr<'hir>, YieldSource),
2934
2935 UnsafeBinderCast(UnsafeBinderCastKind, &'hir Expr<'hir>, Option<&'hir Ty<'hir>>),
2938
2939 Err(rustc_span::ErrorGuaranteed),
2941}
2942
2943#[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: ::rustc_span::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)]
2944pub enum StructTailExpr<'hir> {
2945 None,
2947 Base(&'hir Expr<'hir>),
2950 DefaultFields(Span),
2954 NoneWithError(ErrorGuaranteed),
2960}
2961
2962#[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: ::rustc_span::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)]
2968pub enum QPath<'hir> {
2969 Resolved(Option<&'hir Ty<'hir>>, &'hir Path<'hir>),
2976
2977 TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
2984}
2985
2986impl<'hir> QPath<'hir> {
2987 pub fn span(&self) -> Span {
2989 match *self {
2990 QPath::Resolved(_, path) => path.span,
2991 QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
2992 }
2993 }
2994
2995 pub fn qself_span(&self) -> Span {
2998 match *self {
2999 QPath::Resolved(_, path) => path.span,
3000 QPath::TypeRelative(qself, _) => qself.span,
3001 }
3002 }
3003}
3004
3005#[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: ::rustc_span::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)]
3007pub enum LocalSource {
3008 Normal,
3010 AsyncFn,
3021 AwaitDesugar,
3023 AssignDesugar,
3025 Contract,
3027}
3028
3029#[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: ::rustc_span::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)]
3031pub enum MatchSource {
3032 Normal,
3034 Postfix,
3036 ForLoopDesugar,
3038 TryDesugar(HirId),
3040 AwaitDesugar,
3042 FormatArgs,
3044}
3045
3046impl MatchSource {
3047 #[inline]
3048 pub const fn name(self) -> &'static str {
3049 use MatchSource::*;
3050 match self {
3051 Normal => "match",
3052 Postfix => ".match",
3053 ForLoopDesugar => "for",
3054 TryDesugar(_) => "?",
3055 AwaitDesugar => ".await",
3056 FormatArgs => "format_args!()",
3057 }
3058 }
3059}
3060
3061#[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: ::rustc_span::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)]
3063pub enum LoopSource {
3064 Loop,
3066 While,
3068 ForLoop,
3070}
3071
3072impl LoopSource {
3073 pub fn name(self) -> &'static str {
3074 match self {
3075 LoopSource::Loop => "loop",
3076 LoopSource::While => "while",
3077 LoopSource::ForLoop => "for",
3078 }
3079 }
3080}
3081
3082#[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: ::rustc_span::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)]
3083pub enum LoopIdError {
3084 OutsideLoopScope,
3085 UnlabeledCfInWhileCondition,
3086 UnresolvedLabel,
3087}
3088
3089impl fmt::Display for LoopIdError {
3090 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3091 f.write_str(match self {
3092 LoopIdError::OutsideLoopScope => "not inside loop scope",
3093 LoopIdError::UnlabeledCfInWhileCondition => {
3094 "unlabeled control flow (break or continue) in while condition"
3095 }
3096 LoopIdError::UnresolvedLabel => "label not found",
3097 })
3098 }
3099}
3100
3101#[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: ::rustc_span::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)]
3102pub struct Destination {
3103 pub label: Option<Label>,
3105
3106 pub target_id: Result<HirId, LoopIdError>,
3109}
3110
3111#[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: ::rustc_span::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)]
3113pub enum YieldSource {
3114 Await { expr: Option<HirId> },
3116 Yield,
3118}
3119
3120impl fmt::Display for YieldSource {
3121 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3122 f.write_str(match self {
3123 YieldSource::Await { .. } => "`await`",
3124 YieldSource::Yield => "`yield`",
3125 })
3126 }
3127}
3128
3129#[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: ::rustc_span::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)]
3132pub struct MutTy<'hir> {
3133 pub ty: &'hir Ty<'hir>,
3134 pub mutbl: Mutability,
3135}
3136
3137#[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: ::rustc_span::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)]
3140pub struct FnSig<'hir> {
3141 pub header: FnHeader,
3142 pub decl: &'hir FnDecl<'hir>,
3143 pub span: Span,
3144}
3145
3146#[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: ::rustc_span::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)]
3150pub struct TraitItemId {
3151 pub owner_id: OwnerId,
3152}
3153
3154impl TraitItemId {
3155 #[inline]
3156 pub fn hir_id(&self) -> HirId {
3157 HirId::make_owner(self.owner_id.def_id)
3159 }
3160}
3161
3162#[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: ::rustc_span::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)]
3167pub struct TraitItem<'hir> {
3168 pub ident: Ident,
3169 pub owner_id: OwnerId,
3170 pub generics: &'hir Generics<'hir>,
3171 pub kind: TraitItemKind<'hir>,
3172 pub span: Span,
3173 pub defaultness: Defaultness,
3174 pub has_delayed_lints: bool,
3175}
3176
3177macro_rules! expect_methods_self_kind {
3178 ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3179 $(
3180 #[track_caller]
3181 pub fn $name(&self) -> $ret_ty {
3182 let $pat = &self.kind else { expect_failed(stringify!($name), self) };
3183 $ret_val
3184 }
3185 )*
3186 }
3187}
3188
3189macro_rules! expect_methods_self {
3190 ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3191 $(
3192 #[track_caller]
3193 pub fn $name(&self) -> $ret_ty {
3194 let $pat = self else { expect_failed(stringify!($name), self) };
3195 $ret_val
3196 }
3197 )*
3198 }
3199}
3200
3201#[track_caller]
3202fn expect_failed<T: fmt::Debug>(ident: &'static str, found: T) -> ! {
3203 {
::core::panicking::panic_fmt(format_args!("{0}: found {1:?}", ident,
found));
}panic!("{ident}: found {found:?}")
3204}
3205
3206impl<'hir> TraitItem<'hir> {
3207 #[inline]
3208 pub fn hir_id(&self) -> HirId {
3209 HirId::make_owner(self.owner_id.def_id)
3211 }
3212
3213 pub fn trait_item_id(&self) -> TraitItemId {
3214 TraitItemId { owner_id: self.owner_id }
3215 }
3216
3217 self
let TraitItemKind::Type(bounds, ty) =
&self.kind else { expect_failed("expect_type", self) };
(bounds, *ty);expect_methods_self_kind! {
3218 expect_const, (&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>),
3219 TraitItemKind::Const(ty, rhs, _), (ty, *rhs);
3220
3221 expect_fn, (&FnSig<'hir>, &TraitFn<'hir>),
3222 TraitItemKind::Fn(ty, trfn), (ty, trfn);
3223
3224 expect_type, (GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3225 TraitItemKind::Type(bounds, ty), (bounds, *ty);
3226 }
3227}
3228
3229#[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: ::rustc_span::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)]
3231pub enum TraitFn<'hir> {
3232 Required(&'hir [Option<Ident>]),
3234
3235 Provided(BodyId),
3237}
3238
3239#[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: ::rustc_span::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)]
3240pub enum IsTypeConst {
3241 No,
3242 Yes,
3243}
3244
3245impl From<bool> for IsTypeConst {
3246 fn from(value: bool) -> Self {
3247 if value { Self::Yes } else { Self::No }
3248 }
3249}
3250
3251impl From<IsTypeConst> for bool {
3252 fn from(value: IsTypeConst) -> Self {
3253 #[allow(non_exhaustive_omitted_patterns)] match value {
IsTypeConst::Yes => true,
_ => false,
}matches!(value, IsTypeConst::Yes)
3254 }
3255}
3256
3257#[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: ::rustc_span::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)]
3259pub enum TraitItemKind<'hir> {
3260 Const(&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>, IsTypeConst),
3265 Fn(FnSig<'hir>, TraitFn<'hir>),
3267 Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3270}
3271
3272#[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: ::rustc_span::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)]
3276pub struct ImplItemId {
3277 pub owner_id: OwnerId,
3278}
3279
3280impl ImplItemId {
3281 #[inline]
3282 pub fn hir_id(&self) -> HirId {
3283 HirId::make_owner(self.owner_id.def_id)
3285 }
3286}
3287
3288#[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: ::rustc_span::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)]
3292pub struct ImplItem<'hir> {
3293 pub ident: Ident,
3294 pub owner_id: OwnerId,
3295 pub generics: &'hir Generics<'hir>,
3296 pub kind: ImplItemKind<'hir>,
3297 pub impl_kind: ImplItemImplKind,
3298 pub span: Span,
3299 pub has_delayed_lints: bool,
3300}
3301
3302#[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: ::rustc_span::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)]
3303pub enum ImplItemImplKind {
3304 Inherent {
3305 vis_span: Span,
3306 },
3307 Trait {
3308 defaultness: Defaultness,
3309 trait_item_def_id: Result<DefId, ErrorGuaranteed>,
3311 },
3312}
3313
3314impl<'hir> ImplItem<'hir> {
3315 #[inline]
3316 pub fn hir_id(&self) -> HirId {
3317 HirId::make_owner(self.owner_id.def_id)
3319 }
3320
3321 pub fn impl_item_id(&self) -> ImplItemId {
3322 ImplItemId { owner_id: self.owner_id }
3323 }
3324
3325 pub fn vis_span(&self) -> Option<Span> {
3326 match self.impl_kind {
3327 ImplItemImplKind::Trait { .. } => None,
3328 ImplItemImplKind::Inherent { vis_span, .. } => Some(vis_span),
3329 }
3330 }
3331
3332 self
let ImplItemKind::Type(ty) =
&self.kind else { expect_failed("expect_type", self) };
ty;expect_methods_self_kind! {
3333 expect_const, (&'hir Ty<'hir>, ConstItemRhs<'hir>), ImplItemKind::Const(ty, rhs), (ty, *rhs);
3334 expect_fn, (&FnSig<'hir>, BodyId), ImplItemKind::Fn(ty, body), (ty, *body);
3335 expect_type, &'hir Ty<'hir>, ImplItemKind::Type(ty), ty;
3336 }
3337}
3338
3339#[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: ::rustc_span::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)]
3341pub enum ImplItemKind<'hir> {
3342 Const(&'hir Ty<'hir>, ConstItemRhs<'hir>),
3345 Fn(FnSig<'hir>, BodyId),
3347 Type(&'hir Ty<'hir>),
3349}
3350
3351#[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: ::rustc_span::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)]
3362pub struct AssocItemConstraint<'hir> {
3363 #[stable_hasher(ignore)]
3364 pub hir_id: HirId,
3365 pub ident: Ident,
3366 pub gen_args: &'hir GenericArgs<'hir>,
3367 pub kind: AssocItemConstraintKind<'hir>,
3368 pub span: Span,
3369}
3370
3371impl<'hir> AssocItemConstraint<'hir> {
3372 pub fn ty(self) -> Option<&'hir Ty<'hir>> {
3374 match self.kind {
3375 AssocItemConstraintKind::Equality { term: Term::Ty(ty) } => Some(ty),
3376 _ => None,
3377 }
3378 }
3379
3380 pub fn ct(self) -> Option<&'hir ConstArg<'hir>> {
3382 match self.kind {
3383 AssocItemConstraintKind::Equality { term: Term::Const(ct) } => Some(ct),
3384 _ => None,
3385 }
3386 }
3387}
3388
3389#[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: ::rustc_span::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)]
3390pub enum Term<'hir> {
3391 Ty(&'hir Ty<'hir>),
3392 Const(&'hir ConstArg<'hir>),
3393}
3394
3395impl<'hir> From<&'hir Ty<'hir>> for Term<'hir> {
3396 fn from(ty: &'hir Ty<'hir>) -> Self {
3397 Term::Ty(ty)
3398 }
3399}
3400
3401impl<'hir> From<&'hir ConstArg<'hir>> for Term<'hir> {
3402 fn from(c: &'hir ConstArg<'hir>) -> Self {
3403 Term::Const(c)
3404 }
3405}
3406
3407#[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: ::rustc_span::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)]
3409pub enum AssocItemConstraintKind<'hir> {
3410 Equality { term: Term<'hir> },
3417 Bound { bounds: &'hir [GenericBound<'hir>] },
3419}
3420
3421impl<'hir> AssocItemConstraintKind<'hir> {
3422 pub fn descr(&self) -> &'static str {
3423 match self {
3424 AssocItemConstraintKind::Equality { .. } => "binding",
3425 AssocItemConstraintKind::Bound { .. } => "constraint",
3426 }
3427 }
3428}
3429
3430#[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: ::rustc_span::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)]
3434pub enum AmbigArg {}
3435
3436#[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: ::rustc_span::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)]
3441#[repr(C)]
3442pub struct Ty<'hir, Unambig = ()> {
3443 #[stable_hasher(ignore)]
3444 pub hir_id: HirId,
3445 pub span: Span,
3446 pub kind: TyKind<'hir, Unambig>,
3447}
3448
3449impl<'hir> Ty<'hir, AmbigArg> {
3450 pub fn as_unambig_ty(&self) -> &Ty<'hir> {
3461 let ptr = self as *const Ty<'hir, AmbigArg> as *const Ty<'hir, ()>;
3464 unsafe { &*ptr }
3465 }
3466}
3467
3468impl<'hir> Ty<'hir> {
3469 pub fn try_as_ambig_ty(&self) -> Option<&Ty<'hir, AmbigArg>> {
3475 if let TyKind::Infer(()) = self.kind {
3476 return None;
3477 }
3478
3479 let ptr = self as *const Ty<'hir> as *const Ty<'hir, AmbigArg>;
3483 Some(unsafe { &*ptr })
3484 }
3485}
3486
3487impl<'hir> Ty<'hir, AmbigArg> {
3488 pub fn peel_refs(&self) -> &Ty<'hir> {
3489 let mut final_ty = self.as_unambig_ty();
3490 while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3491 final_ty = ty;
3492 }
3493 final_ty
3494 }
3495}
3496
3497impl<'hir> Ty<'hir> {
3498 pub fn peel_refs(&self) -> &Self {
3499 let mut final_ty = self;
3500 while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3501 final_ty = ty;
3502 }
3503 final_ty
3504 }
3505
3506 pub fn as_generic_param(&self) -> Option<(DefId, Ident)> {
3508 let TyKind::Path(QPath::Resolved(None, path)) = self.kind else {
3509 return None;
3510 };
3511 let [segment] = &path.segments else {
3512 return None;
3513 };
3514 match path.res {
3515 Res::Def(DefKind::TyParam, def_id) | Res::SelfTyParam { trait_: def_id } => {
3516 Some((def_id, segment.ident))
3517 }
3518 _ => None,
3519 }
3520 }
3521
3522 pub fn find_self_aliases(&self) -> Vec<Span> {
3523 use crate::intravisit::Visitor;
3524 struct MyVisitor(Vec<Span>);
3525 impl<'v> Visitor<'v> for MyVisitor {
3526 fn visit_ty(&mut self, t: &'v Ty<'v, AmbigArg>) {
3527 if #[allow(non_exhaustive_omitted_patterns)] match &t.kind {
TyKind::Path(QPath::Resolved(_, Path {
res: crate::def::Res::SelfTyAlias { .. }, .. })) => true,
_ => false,
}matches!(
3528 &t.kind,
3529 TyKind::Path(QPath::Resolved(
3530 _,
3531 Path { res: crate::def::Res::SelfTyAlias { .. }, .. },
3532 ))
3533 ) {
3534 self.0.push(t.span);
3535 return;
3536 }
3537 crate::intravisit::walk_ty(self, t);
3538 }
3539 }
3540
3541 let mut my_visitor = MyVisitor(::alloc::vec::Vec::new()vec![]);
3542 my_visitor.visit_ty_unambig(self);
3543 my_visitor.0
3544 }
3545
3546 pub fn is_suggestable_infer_ty(&self) -> bool {
3549 fn are_suggestable_generic_args(generic_args: &[GenericArg<'_>]) -> bool {
3550 generic_args.iter().any(|arg| match arg {
3551 GenericArg::Type(ty) => ty.as_unambig_ty().is_suggestable_infer_ty(),
3552 GenericArg::Infer(_) => true,
3553 _ => false,
3554 })
3555 }
3556 {
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:3556",
"rustc_hir::hir", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir/src/hir.rs"),
::tracing_core::__macro_support::Option::Some(3556u32),
::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);
3557 match &self.kind {
3558 TyKind::Infer(()) => true,
3559 TyKind::Slice(ty) => ty.is_suggestable_infer_ty(),
3560 TyKind::Array(ty, length) => {
3561 ty.is_suggestable_infer_ty() || #[allow(non_exhaustive_omitted_patterns)] match length.kind {
ConstArgKind::Infer(..) => true,
_ => false,
}matches!(length.kind, ConstArgKind::Infer(..))
3562 }
3563 TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
3564 TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),
3565 TyKind::Path(QPath::TypeRelative(ty, segment)) => {
3566 ty.is_suggestable_infer_ty() || are_suggestable_generic_args(segment.args().args)
3567 }
3568 TyKind::Path(QPath::Resolved(ty_opt, Path { segments, .. })) => {
3569 ty_opt.is_some_and(Self::is_suggestable_infer_ty)
3570 || segments
3571 .iter()
3572 .any(|segment| are_suggestable_generic_args(segment.args().args))
3573 }
3574 _ => false,
3575 }
3576 }
3577}
3578
3579#[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: ::rustc_span::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)]
3581pub enum PrimTy {
3582 Int(IntTy),
3583 Uint(UintTy),
3584 Float(FloatTy),
3585 Str,
3586 Bool,
3587 Char,
3588}
3589
3590impl PrimTy {
3591 pub const ALL: [Self; 19] = [
3593 Self::Int(IntTy::I8),
3595 Self::Int(IntTy::I16),
3596 Self::Int(IntTy::I32),
3597 Self::Int(IntTy::I64),
3598 Self::Int(IntTy::I128),
3599 Self::Int(IntTy::Isize),
3600 Self::Uint(UintTy::U8),
3601 Self::Uint(UintTy::U16),
3602 Self::Uint(UintTy::U32),
3603 Self::Uint(UintTy::U64),
3604 Self::Uint(UintTy::U128),
3605 Self::Uint(UintTy::Usize),
3606 Self::Float(FloatTy::F16),
3607 Self::Float(FloatTy::F32),
3608 Self::Float(FloatTy::F64),
3609 Self::Float(FloatTy::F128),
3610 Self::Bool,
3611 Self::Char,
3612 Self::Str,
3613 ];
3614
3615 pub fn name_str(self) -> &'static str {
3619 match self {
3620 PrimTy::Int(i) => i.name_str(),
3621 PrimTy::Uint(u) => u.name_str(),
3622 PrimTy::Float(f) => f.name_str(),
3623 PrimTy::Str => "str",
3624 PrimTy::Bool => "bool",
3625 PrimTy::Char => "char",
3626 }
3627 }
3628
3629 pub fn name(self) -> Symbol {
3630 match self {
3631 PrimTy::Int(i) => i.name(),
3632 PrimTy::Uint(u) => u.name(),
3633 PrimTy::Float(f) => f.name(),
3634 PrimTy::Str => sym::str,
3635 PrimTy::Bool => sym::bool,
3636 PrimTy::Char => sym::char,
3637 }
3638 }
3639
3640 pub fn from_name(name: Symbol) -> Option<Self> {
3643 let ty = match name {
3644 sym::i8 => Self::Int(IntTy::I8),
3646 sym::i16 => Self::Int(IntTy::I16),
3647 sym::i32 => Self::Int(IntTy::I32),
3648 sym::i64 => Self::Int(IntTy::I64),
3649 sym::i128 => Self::Int(IntTy::I128),
3650 sym::isize => Self::Int(IntTy::Isize),
3651 sym::u8 => Self::Uint(UintTy::U8),
3652 sym::u16 => Self::Uint(UintTy::U16),
3653 sym::u32 => Self::Uint(UintTy::U32),
3654 sym::u64 => Self::Uint(UintTy::U64),
3655 sym::u128 => Self::Uint(UintTy::U128),
3656 sym::usize => Self::Uint(UintTy::Usize),
3657 sym::f16 => Self::Float(FloatTy::F16),
3658 sym::f32 => Self::Float(FloatTy::F32),
3659 sym::f64 => Self::Float(FloatTy::F64),
3660 sym::f128 => Self::Float(FloatTy::F128),
3661 sym::bool => Self::Bool,
3662 sym::char => Self::Char,
3663 sym::str => Self::Str,
3664 _ => return None,
3665 };
3666 Some(ty)
3667 }
3668}
3669
3670#[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: ::rustc_span::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)]
3671pub struct FnPtrTy<'hir> {
3672 pub safety: Safety,
3673 pub abi: ExternAbi,
3674 pub generic_params: &'hir [GenericParam<'hir>],
3675 pub decl: &'hir FnDecl<'hir>,
3676 pub param_idents: &'hir [Option<Ident>],
3679}
3680
3681#[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: ::rustc_span::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)]
3682pub struct UnsafeBinderTy<'hir> {
3683 pub generic_params: &'hir [GenericParam<'hir>],
3684 pub inner_ty: &'hir Ty<'hir>,
3685}
3686
3687#[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: ::rustc_span::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)]
3688pub struct OpaqueTy<'hir> {
3689 #[stable_hasher(ignore)]
3690 pub hir_id: HirId,
3691 pub def_id: LocalDefId,
3692 pub bounds: GenericBounds<'hir>,
3693 pub origin: OpaqueTyOrigin<LocalDefId>,
3694 pub span: Span,
3695}
3696
3697#[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: ::rustc_span::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)]
3698pub enum PreciseCapturingArgKind<T, U> {
3699 Lifetime(T),
3700 Param(U),
3702}
3703
3704pub type PreciseCapturingArg<'hir> =
3705 PreciseCapturingArgKind<&'hir Lifetime, PreciseCapturingNonLifetimeArg>;
3706
3707impl PreciseCapturingArg<'_> {
3708 pub fn hir_id(self) -> HirId {
3709 match self {
3710 PreciseCapturingArg::Lifetime(lt) => lt.hir_id,
3711 PreciseCapturingArg::Param(param) => param.hir_id,
3712 }
3713 }
3714
3715 pub fn name(self) -> Symbol {
3716 match self {
3717 PreciseCapturingArg::Lifetime(lt) => lt.ident.name,
3718 PreciseCapturingArg::Param(param) => param.ident.name,
3719 }
3720 }
3721}
3722
3723#[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: ::rustc_span::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)]
3728pub struct PreciseCapturingNonLifetimeArg {
3729 #[stable_hasher(ignore)]
3730 pub hir_id: HirId,
3731 pub ident: Ident,
3732 pub res: Res,
3733}
3734
3735#[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)]
3736#[derive(const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for RpitContext where __CTX: ::rustc_span::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)]
3737pub enum RpitContext {
3738 Trait,
3739 TraitImpl,
3740}
3741
3742#[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)]
3744#[derive(const _: () =
{
impl<D, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
OpaqueTyOrigin<D> where __CTX: ::rustc_span::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)]
3745pub enum OpaqueTyOrigin<D> {
3746 FnReturn {
3748 parent: D,
3750 in_trait_or_impl: Option<RpitContext>,
3752 },
3753 AsyncFn {
3755 parent: D,
3757 in_trait_or_impl: Option<RpitContext>,
3759 },
3760 TyAlias {
3762 parent: D,
3764 in_assoc_ty: bool,
3766 },
3767}
3768
3769#[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: ::rustc_span::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)]
3771pub struct DelegationGenerics {
3772 pub parent_args_segment_id: Option<HirId>,
3773 pub child_args_segment_id: Option<HirId>,
3774}
3775
3776#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InferDelegationSig<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
InferDelegationSig::Input(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Input",
&__self_0),
InferDelegationSig::Output(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Output",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InferDelegationSig<'hir> {
#[inline]
fn clone(&self) -> InferDelegationSig<'hir> {
let _: ::core::clone::AssertParamIsClone<usize>;
let _: ::core::clone::AssertParamIsClone<&'hir DelegationGenerics>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InferDelegationSig<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::cmp::PartialEq for InferDelegationSig<'hir> {
#[inline]
fn eq(&self, other: &InferDelegationSig<'hir>) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(InferDelegationSig::Input(__self_0),
InferDelegationSig::Input(__arg1_0)) =>
__self_0 == __arg1_0,
(InferDelegationSig::Output(__self_0),
InferDelegationSig::Output(__arg1_0)) =>
__self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl<'hir> ::core::cmp::Eq for InferDelegationSig<'hir> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<usize>;
let _: ::core::cmp::AssertParamIsEq<&'hir DelegationGenerics>;
}
}Eq, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
InferDelegationSig<'hir> where
__CTX: ::rustc_span::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 {
InferDelegationSig::Input(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
InferDelegationSig::Output(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3777pub enum InferDelegationSig<'hir> {
3778 Input(usize),
3779 Output(&'hir DelegationGenerics),
3781}
3782
3783#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InferDelegation<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
InferDelegation::DefId(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "DefId",
&__self_0),
InferDelegation::Sig(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Sig",
__self_0, &__self_1),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InferDelegation<'hir> {
#[inline]
fn clone(&self) -> InferDelegation<'hir> {
let _: ::core::clone::AssertParamIsClone<DefId>;
let _: ::core::clone::AssertParamIsClone<InferDelegationSig<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InferDelegation<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::cmp::PartialEq for InferDelegation<'hir> {
#[inline]
fn eq(&self, other: &InferDelegation<'hir>) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(InferDelegation::DefId(__self_0),
InferDelegation::DefId(__arg1_0)) => __self_0 == __arg1_0,
(InferDelegation::Sig(__self_0, __self_1),
InferDelegation::Sig(__arg1_0, __arg1_1)) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl<'hir> ::core::cmp::Eq for InferDelegation<'hir> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<DefId>;
let _: ::core::cmp::AssertParamIsEq<InferDelegationSig<'hir>>;
}
}Eq, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
InferDelegation<'hir> where __CTX: ::rustc_span::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 {
InferDelegation::DefId(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
InferDelegation::Sig(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3784pub enum InferDelegation<'hir> {
3785 DefId(DefId),
3788 Sig(DefId, InferDelegationSig<'hir>),
3790}
3791
3792#[repr(u8, C)]
3798#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
TyKind<'hir, Unambig> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TyKind::InferDelegation(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"InferDelegation", &__self_0),
TyKind::Slice(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Slice",
&__self_0),
TyKind::Array(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Array",
__self_0, &__self_1),
TyKind::Ptr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ptr",
&__self_0),
TyKind::Ref(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Ref",
__self_0, &__self_1),
TyKind::FnPtr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "FnPtr",
&__self_0),
TyKind::UnsafeBinder(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"UnsafeBinder", &__self_0),
TyKind::Never => ::core::fmt::Formatter::write_str(f, "Never"),
TyKind::Tup(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tup",
&__self_0),
TyKind::Path(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
&__self_0),
TyKind::OpaqueDef(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"OpaqueDef", &__self_0),
TyKind::TraitAscription(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TraitAscription", &__self_0),
TyKind::TraitObject(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"TraitObject", __self_0, &__self_1),
TyKind::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
TyKind::Pat(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Pat",
__self_0, &__self_1),
TyKind::FieldOf(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"FieldOf", __self_0, &__self_1),
TyKind::Infer(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
TyKind<'hir, Unambig> {
#[inline]
fn clone(&self) -> TyKind<'hir, Unambig> {
match self {
TyKind::InferDelegation(__self_0) =>
TyKind::InferDelegation(::core::clone::Clone::clone(__self_0)),
TyKind::Slice(__self_0) =>
TyKind::Slice(::core::clone::Clone::clone(__self_0)),
TyKind::Array(__self_0, __self_1) =>
TyKind::Array(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::Ptr(__self_0) =>
TyKind::Ptr(::core::clone::Clone::clone(__self_0)),
TyKind::Ref(__self_0, __self_1) =>
TyKind::Ref(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::FnPtr(__self_0) =>
TyKind::FnPtr(::core::clone::Clone::clone(__self_0)),
TyKind::UnsafeBinder(__self_0) =>
TyKind::UnsafeBinder(::core::clone::Clone::clone(__self_0)),
TyKind::Never => TyKind::Never,
TyKind::Tup(__self_0) =>
TyKind::Tup(::core::clone::Clone::clone(__self_0)),
TyKind::Path(__self_0) =>
TyKind::Path(::core::clone::Clone::clone(__self_0)),
TyKind::OpaqueDef(__self_0) =>
TyKind::OpaqueDef(::core::clone::Clone::clone(__self_0)),
TyKind::TraitAscription(__self_0) =>
TyKind::TraitAscription(::core::clone::Clone::clone(__self_0)),
TyKind::TraitObject(__self_0, __self_1) =>
TyKind::TraitObject(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::Err(__self_0) =>
TyKind::Err(::core::clone::Clone::clone(__self_0)),
TyKind::Pat(__self_0, __self_1) =>
TyKind::Pat(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::FieldOf(__self_0, __self_1) =>
TyKind::FieldOf(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::Infer(__self_0) =>
TyKind::Infer(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
TyKind<'hir, Unambig> {
}Copy, const _: () =
{
impl<'hir, Unambig, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TyKind<'hir, Unambig> where
__CTX: ::rustc_span::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) => {
{ __binding_0.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)]
3799pub enum TyKind<'hir, Unambig = ()> {
3800 InferDelegation(InferDelegation<'hir>),
3802 Slice(&'hir Ty<'hir>),
3804 Array(&'hir Ty<'hir>, &'hir ConstArg<'hir>),
3806 Ptr(MutTy<'hir>),
3808 Ref(&'hir Lifetime, MutTy<'hir>),
3810 FnPtr(&'hir FnPtrTy<'hir>),
3812 UnsafeBinder(&'hir UnsafeBinderTy<'hir>),
3814 Never,
3816 Tup(&'hir [Ty<'hir>]),
3818 Path(QPath<'hir>),
3823 OpaqueDef(&'hir OpaqueTy<'hir>),
3825 TraitAscription(GenericBounds<'hir>),
3827 TraitObject(&'hir [PolyTraitRef<'hir>], TaggedRef<'hir, Lifetime, TraitObjectSyntax>),
3833 Err(rustc_span::ErrorGuaranteed),
3835 Pat(&'hir Ty<'hir>, &'hir TyPat<'hir>),
3837 FieldOf(&'hir Ty<'hir>, &'hir TyFieldPath),
3841 Infer(Unambig),
3847}
3848
3849#[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: ::rustc_span::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)]
3850pub enum InlineAsmOperand<'hir> {
3851 In {
3852 reg: InlineAsmRegOrRegClass,
3853 expr: &'hir Expr<'hir>,
3854 },
3855 Out {
3856 reg: InlineAsmRegOrRegClass,
3857 late: bool,
3858 expr: Option<&'hir Expr<'hir>>,
3859 },
3860 InOut {
3861 reg: InlineAsmRegOrRegClass,
3862 late: bool,
3863 expr: &'hir Expr<'hir>,
3864 },
3865 SplitInOut {
3866 reg: InlineAsmRegOrRegClass,
3867 late: bool,
3868 in_expr: &'hir Expr<'hir>,
3869 out_expr: Option<&'hir Expr<'hir>>,
3870 },
3871 Const {
3872 anon_const: ConstBlock,
3873 },
3874 SymFn {
3875 expr: &'hir Expr<'hir>,
3876 },
3877 SymStatic {
3878 path: QPath<'hir>,
3879 def_id: DefId,
3880 },
3881 Label {
3882 block: &'hir Block<'hir>,
3883 },
3884}
3885
3886impl<'hir> InlineAsmOperand<'hir> {
3887 pub fn reg(&self) -> Option<InlineAsmRegOrRegClass> {
3888 match *self {
3889 Self::In { reg, .. }
3890 | Self::Out { reg, .. }
3891 | Self::InOut { reg, .. }
3892 | Self::SplitInOut { reg, .. } => Some(reg),
3893 Self::Const { .. }
3894 | Self::SymFn { .. }
3895 | Self::SymStatic { .. }
3896 | Self::Label { .. } => None,
3897 }
3898 }
3899
3900 pub fn is_clobber(&self) -> bool {
3901 #[allow(non_exhaustive_omitted_patterns)] match self {
InlineAsmOperand::Out {
reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None } => true,
_ => false,
}matches!(
3902 self,
3903 InlineAsmOperand::Out { reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None }
3904 )
3905 }
3906}
3907
3908#[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: ::rustc_span::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)]
3909pub struct InlineAsm<'hir> {
3910 pub asm_macro: ast::AsmMacro,
3911 pub template: &'hir [InlineAsmTemplatePiece],
3912 pub template_strs: &'hir [(Symbol, Option<Symbol>, Span)],
3913 pub operands: &'hir [(InlineAsmOperand<'hir>, Span)],
3914 pub options: InlineAsmOptions,
3915 pub line_spans: &'hir [Span],
3916}
3917
3918impl InlineAsm<'_> {
3919 pub fn contains_label(&self) -> bool {
3920 self.operands.iter().any(|x| #[allow(non_exhaustive_omitted_patterns)] match x.0 {
InlineAsmOperand::Label { .. } => true,
_ => false,
}matches!(x.0, InlineAsmOperand::Label { .. }))
3921 }
3922}
3923
3924#[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: ::rustc_span::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)]
3926pub struct Param<'hir> {
3927 #[stable_hasher(ignore)]
3928 pub hir_id: HirId,
3929 pub pat: &'hir Pat<'hir>,
3930 pub ty_span: Span,
3931 pub span: Span,
3932}
3933
3934#[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: ::rustc_span::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)]
3936pub struct FnDecl<'hir> {
3937 pub inputs: &'hir [Ty<'hir>],
3941 pub output: FnRetTy<'hir>,
3942 pub c_variadic: bool,
3943 pub implicit_self: ImplicitSelfKind,
3945 pub lifetime_elision_allowed: bool,
3947}
3948
3949impl<'hir> FnDecl<'hir> {
3950 pub fn opt_delegation_sig_id(&self) -> Option<DefId> {
3951 if let FnRetTy::Return(ty) = self.output
3952 && let TyKind::InferDelegation(InferDelegation::Sig(sig_id, _)) = ty.kind
3953 {
3954 return Some(sig_id);
3955 }
3956 None
3957 }
3958
3959 pub fn opt_delegation_generics(&self) -> Option<&'hir DelegationGenerics> {
3960 if let FnRetTy::Return(ty) = self.output
3961 && let TyKind::InferDelegation(InferDelegation::Sig(_, kind)) = ty.kind
3962 && let InferDelegationSig::Output(generics) = kind
3963 {
3964 return Some(generics);
3965 }
3966
3967 None
3968 }
3969}
3970
3971#[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: ::rustc_span::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)]
3973pub enum ImplicitSelfKind {
3974 Imm,
3976 Mut,
3978 RefImm,
3980 RefMut,
3982 None,
3985}
3986
3987impl ImplicitSelfKind {
3988 pub fn has_implicit_self(&self) -> bool {
3990 !#[allow(non_exhaustive_omitted_patterns)] match *self {
ImplicitSelfKind::None => true,
_ => false,
}matches!(*self, ImplicitSelfKind::None)
3991 }
3992}
3993
3994#[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: ::rustc_span::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)]
3995pub enum IsAsync {
3996 Async(Span),
3997 NotAsync,
3998}
3999
4000impl IsAsync {
4001 pub fn is_async(self) -> bool {
4002 #[allow(non_exhaustive_omitted_patterns)] match self {
IsAsync::Async(_) => true,
_ => false,
}matches!(self, IsAsync::Async(_))
4003 }
4004}
4005
4006#[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: ::rustc_span::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)]
4007#[derive(#[automatically_derived]
impl ::core::default::Default for Defaultness {
#[inline]
fn default() -> Defaultness { Self::Final }
}Default)]
4008pub enum Defaultness {
4009 Default {
4010 has_value: bool,
4011 },
4012 #[default]
4013 Final,
4014}
4015
4016impl Defaultness {
4017 pub fn has_value(&self) -> bool {
4018 match *self {
4019 Defaultness::Default { has_value } => has_value,
4020 Defaultness::Final => true,
4021 }
4022 }
4023
4024 pub fn is_final(&self) -> bool {
4025 *self == Defaultness::Final
4026 }
4027
4028 pub fn is_default(&self) -> bool {
4029 #[allow(non_exhaustive_omitted_patterns)] match *self {
Defaultness::Default { .. } => true,
_ => false,
}matches!(*self, Defaultness::Default { .. })
4030 }
4031}
4032
4033#[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: ::rustc_span::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)]
4034pub enum FnRetTy<'hir> {
4035 DefaultReturn(Span),
4041 Return(&'hir Ty<'hir>),
4043}
4044
4045impl<'hir> FnRetTy<'hir> {
4046 #[inline]
4047 pub fn span(&self) -> Span {
4048 match *self {
4049 Self::DefaultReturn(span) => span,
4050 Self::Return(ref ty) => ty.span,
4051 }
4052 }
4053
4054 pub fn is_suggestable_infer_ty(&self) -> Option<&'hir Ty<'hir>> {
4055 if let Self::Return(ty) = self
4056 && ty.is_suggestable_infer_ty()
4057 {
4058 return Some(*ty);
4059 }
4060 None
4061 }
4062}
4063
4064#[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: ::rustc_span::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)]
4066pub enum ClosureBinder {
4067 Default,
4069 For { span: Span },
4073}
4074
4075#[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: ::rustc_span::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)]
4076pub struct Mod<'hir> {
4077 pub spans: ModSpans,
4078 pub item_ids: &'hir [ItemId],
4079}
4080
4081#[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: ::rustc_span::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)]
4082pub struct ModSpans {
4083 pub inner_span: Span,
4087 pub inject_use_span: Span,
4088}
4089
4090#[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: ::rustc_span::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)]
4091pub struct EnumDef<'hir> {
4092 pub variants: &'hir [Variant<'hir>],
4093}
4094
4095#[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: ::rustc_span::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)]
4096pub struct Variant<'hir> {
4097 pub ident: Ident,
4099 #[stable_hasher(ignore)]
4101 pub hir_id: HirId,
4102 pub def_id: LocalDefId,
4103 pub data: VariantData<'hir>,
4105 pub disr_expr: Option<&'hir AnonConst>,
4107 pub span: Span,
4109}
4110
4111#[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: ::rustc_span::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)]
4112pub enum UseKind {
4113 Single(Ident),
4120
4121 Glob,
4123
4124 ListStem,
4128}
4129
4130#[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: ::rustc_span::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)]
4137pub struct TraitRef<'hir> {
4138 pub path: &'hir Path<'hir>,
4139 #[stable_hasher(ignore)]
4141 pub hir_ref_id: HirId,
4142}
4143
4144impl TraitRef<'_> {
4145 pub fn trait_def_id(&self) -> Option<DefId> {
4147 match self.path.res {
4148 Res::Def(DefKind::Trait | DefKind::TraitAlias, did) => Some(did),
4149 Res::Err => None,
4150 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"),
4151 }
4152 }
4153}
4154
4155#[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: ::rustc_span::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)]
4156pub struct PolyTraitRef<'hir> {
4157 pub bound_generic_params: &'hir [GenericParam<'hir>],
4159
4160 pub modifiers: TraitBoundModifiers,
4164
4165 pub trait_ref: TraitRef<'hir>,
4167
4168 pub span: Span,
4169}
4170
4171#[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: ::rustc_span::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)]
4172pub struct FieldDef<'hir> {
4173 pub span: Span,
4174 pub vis_span: Span,
4175 pub ident: Ident,
4176 #[stable_hasher(ignore)]
4177 pub hir_id: HirId,
4178 pub def_id: LocalDefId,
4179 pub ty: &'hir Ty<'hir>,
4180 pub safety: Safety,
4181 pub default: Option<&'hir AnonConst>,
4182}
4183
4184impl FieldDef<'_> {
4185 pub fn is_positional(&self) -> bool {
4187 self.ident.as_str().as_bytes()[0].is_ascii_digit()
4188 }
4189}
4190
4191#[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: ::rustc_span::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)]
4193pub enum VariantData<'hir> {
4194 Struct { fields: &'hir [FieldDef<'hir>], recovered: ast::Recovered },
4198 Tuple(&'hir [FieldDef<'hir>], #[stable_hasher(ignore)] HirId, LocalDefId),
4202 Unit(#[stable_hasher(ignore)] HirId, LocalDefId),
4206}
4207
4208impl<'hir> VariantData<'hir> {
4209 pub fn fields(&self) -> &'hir [FieldDef<'hir>] {
4211 match *self {
4212 VariantData::Struct { fields, .. } | VariantData::Tuple(fields, ..) => fields,
4213 _ => &[],
4214 }
4215 }
4216
4217 pub fn ctor(&self) -> Option<(CtorKind, HirId, LocalDefId)> {
4218 match *self {
4219 VariantData::Tuple(_, hir_id, def_id) => Some((CtorKind::Fn, hir_id, def_id)),
4220 VariantData::Unit(hir_id, def_id) => Some((CtorKind::Const, hir_id, def_id)),
4221 VariantData::Struct { .. } => None,
4222 }
4223 }
4224
4225 #[inline]
4226 pub fn ctor_kind(&self) -> Option<CtorKind> {
4227 self.ctor().map(|(kind, ..)| kind)
4228 }
4229
4230 #[inline]
4232 pub fn ctor_hir_id(&self) -> Option<HirId> {
4233 self.ctor().map(|(_, hir_id, _)| hir_id)
4234 }
4235
4236 #[inline]
4238 pub fn ctor_def_id(&self) -> Option<LocalDefId> {
4239 self.ctor().map(|(.., def_id)| def_id)
4240 }
4241}
4242
4243#[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: ::rustc_span::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)]
4247pub struct ItemId {
4248 pub owner_id: OwnerId,
4249}
4250
4251impl ItemId {
4252 #[inline]
4253 pub fn hir_id(&self) -> HirId {
4254 HirId::make_owner(self.owner_id.def_id)
4256 }
4257}
4258
4259#[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: ::rustc_span::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)]
4268pub struct Item<'hir> {
4269 pub owner_id: OwnerId,
4270 pub kind: ItemKind<'hir>,
4271 pub span: Span,
4272 pub vis_span: Span,
4273 pub has_delayed_lints: bool,
4274 pub eii: bool,
4277}
4278
4279impl<'hir> Item<'hir> {
4280 #[inline]
4281 pub fn hir_id(&self) -> HirId {
4282 HirId::make_owner(self.owner_id.def_id)
4284 }
4285
4286 pub fn item_id(&self) -> ItemId {
4287 ItemId { owner_id: self.owner_id }
4288 }
4289
4290 pub fn is_adt(&self) -> bool {
4293 #[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(..))
4294 }
4295
4296 pub fn is_struct_or_union(&self) -> bool {
4298 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ItemKind::Struct(..) | ItemKind::Union(..) => true,
_ => false,
}matches!(self.kind, ItemKind::Struct(..) | ItemKind::Union(..))
4299 }
4300
4301 self
let ItemKind::Impl(imp) =
&self.kind else { expect_failed("expect_impl", self) };
imp;expect_methods_self_kind! {
4302 expect_extern_crate, (Option<Symbol>, Ident),
4303 ItemKind::ExternCrate(s, ident), (*s, *ident);
4304
4305 expect_use, (&'hir UsePath<'hir>, UseKind), ItemKind::Use(p, uk), (p, *uk);
4306
4307 expect_static, (Mutability, Ident, &'hir Ty<'hir>, BodyId),
4308 ItemKind::Static(mutbl, ident, ty, body), (*mutbl, *ident, ty, *body);
4309
4310 expect_const, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4311 ItemKind::Const(ident, generics, ty, rhs), (*ident, generics, ty, *rhs);
4312
4313 expect_fn, (Ident, &FnSig<'hir>, &'hir Generics<'hir>, BodyId),
4314 ItemKind::Fn { ident, sig, generics, body, .. }, (*ident, sig, generics, *body);
4315
4316 expect_macro, (Ident, &ast::MacroDef, MacroKinds),
4317 ItemKind::Macro(ident, def, mk), (*ident, def, *mk);
4318
4319 expect_mod, (Ident, &'hir Mod<'hir>), ItemKind::Mod(ident, m), (*ident, m);
4320
4321 expect_foreign_mod, (ExternAbi, &'hir [ForeignItemId]),
4322 ItemKind::ForeignMod { abi, items }, (*abi, items);
4323
4324 expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm { asm, .. }, asm;
4325
4326 expect_ty_alias, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4327 ItemKind::TyAlias(ident, generics, ty), (*ident, generics, ty);
4328
4329 expect_enum, (Ident, &'hir Generics<'hir>, &EnumDef<'hir>),
4330 ItemKind::Enum(ident, generics, def), (*ident, generics, def);
4331
4332 expect_struct, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4333 ItemKind::Struct(ident, generics, data), (*ident, generics, data);
4334
4335 expect_union, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4336 ItemKind::Union(ident, generics, data), (*ident, generics, data);
4337
4338 expect_trait,
4339 (
4340 Constness,
4341 IsAuto,
4342 Safety,
4343 Ident,
4344 &'hir Generics<'hir>,
4345 GenericBounds<'hir>,
4346 &'hir [TraitItemId]
4347 ),
4348 ItemKind::Trait(constness, is_auto, safety, ident, generics, bounds, items),
4349 (*constness, *is_auto, *safety, *ident, generics, bounds, items);
4350
4351 expect_trait_alias, (Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4352 ItemKind::TraitAlias(constness, ident, generics, bounds), (*constness, *ident, generics, bounds);
4353
4354 expect_impl, &Impl<'hir>, ItemKind::Impl(imp), imp;
4355 }
4356}
4357
4358#[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)]
4359#[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: ::rustc_span::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)]
4360pub enum Safety {
4361 #[default]
4366 Unsafe,
4367 Safe,
4368}
4369
4370impl Safety {
4371 pub fn prefix_str(self) -> &'static str {
4372 match self {
4373 Self::Unsafe => "unsafe ",
4374 Self::Safe => "",
4375 }
4376 }
4377
4378 #[inline]
4379 pub fn is_unsafe(self) -> bool {
4380 !self.is_safe()
4381 }
4382
4383 #[inline]
4384 pub fn is_safe(self) -> bool {
4385 match self {
4386 Self::Unsafe => false,
4387 Self::Safe => true,
4388 }
4389 }
4390}
4391
4392impl fmt::Display for Safety {
4393 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4394 f.write_str(match *self {
4395 Self::Unsafe => "unsafe",
4396 Self::Safe => "safe",
4397 })
4398 }
4399}
4400
4401#[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: ::rustc_span::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)]
4402#[derive(#[automatically_derived]
impl ::core::default::Default for Constness {
#[inline]
fn default() -> Constness { Self::Const }
}Default)]
4403pub enum Constness {
4404 #[default]
4405 Const,
4406 NotConst,
4407}
4408
4409impl fmt::Display for Constness {
4410 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4411 f.write_str(match *self {
4412 Self::Const => "const",
4413 Self::NotConst => "non-const",
4414 })
4415 }
4416}
4417
4418#[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: ::rustc_span::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)]
4423pub enum HeaderSafety {
4424 SafeTargetFeatures,
4430 Normal(Safety),
4431}
4432
4433impl From<Safety> for HeaderSafety {
4434 fn from(v: Safety) -> Self {
4435 Self::Normal(v)
4436 }
4437}
4438
4439#[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: ::rustc_span::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)]
4440pub struct FnHeader {
4441 pub safety: HeaderSafety,
4442 pub constness: Constness,
4443 pub asyncness: IsAsync,
4444 pub abi: ExternAbi,
4445}
4446
4447impl FnHeader {
4448 pub fn is_async(&self) -> bool {
4449 #[allow(non_exhaustive_omitted_patterns)] match self.asyncness {
IsAsync::Async(_) => true,
_ => false,
}matches!(self.asyncness, IsAsync::Async(_))
4450 }
4451
4452 pub fn is_const(&self) -> bool {
4453 #[allow(non_exhaustive_omitted_patterns)] match self.constness {
Constness::Const => true,
_ => false,
}matches!(self.constness, Constness::Const)
4454 }
4455
4456 pub fn is_unsafe(&self) -> bool {
4457 self.safety().is_unsafe()
4458 }
4459
4460 pub fn is_safe(&self) -> bool {
4461 self.safety().is_safe()
4462 }
4463
4464 pub fn safety(&self) -> Safety {
4465 match self.safety {
4466 HeaderSafety::SafeTargetFeatures => Safety::Unsafe,
4467 HeaderSafety::Normal(safety) => safety,
4468 }
4469 }
4470}
4471
4472#[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: ::rustc_span::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)]
4473pub enum ItemKind<'hir> {
4474 ExternCrate(Option<Symbol>, Ident),
4478
4479 Use(&'hir UsePath<'hir>, UseKind),
4485
4486 Static(Mutability, Ident, &'hir Ty<'hir>, BodyId),
4488 Const(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4490 Fn {
4492 sig: FnSig<'hir>,
4493 ident: Ident,
4494 generics: &'hir Generics<'hir>,
4495 body: BodyId,
4496 has_body: bool,
4500 },
4501 Macro(Ident, &'hir ast::MacroDef, MacroKinds),
4503 Mod(Ident, &'hir Mod<'hir>),
4505 ForeignMod { abi: ExternAbi, items: &'hir [ForeignItemId] },
4507 GlobalAsm {
4509 asm: &'hir InlineAsm<'hir>,
4510 fake_body: BodyId,
4516 },
4517 TyAlias(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4519 Enum(Ident, &'hir Generics<'hir>, EnumDef<'hir>),
4521 Struct(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4523 Union(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4525 Trait(
4527 Constness,
4528 IsAuto,
4529 Safety,
4530 Ident,
4531 &'hir Generics<'hir>,
4532 GenericBounds<'hir>,
4533 &'hir [TraitItemId],
4534 ),
4535 TraitAlias(Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4537
4538 Impl(Impl<'hir>),
4540}
4541
4542#[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: ::rustc_span::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)]
4547pub struct Impl<'hir> {
4548 pub generics: &'hir Generics<'hir>,
4549 pub of_trait: Option<&'hir TraitImplHeader<'hir>>,
4550 pub self_ty: &'hir Ty<'hir>,
4551 pub items: &'hir [ImplItemId],
4552 pub constness: Constness,
4553}
4554
4555#[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: ::rustc_span::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)]
4556pub struct TraitImplHeader<'hir> {
4557 pub safety: Safety,
4558 pub polarity: ImplPolarity,
4559 pub defaultness: Defaultness,
4560 pub defaultness_span: Option<Span>,
4563 pub trait_ref: TraitRef<'hir>,
4564}
4565
4566impl ItemKind<'_> {
4567 pub fn ident(&self) -> Option<Ident> {
4568 match *self {
4569 ItemKind::ExternCrate(_, ident)
4570 | ItemKind::Use(_, UseKind::Single(ident))
4571 | ItemKind::Static(_, ident, ..)
4572 | ItemKind::Const(ident, ..)
4573 | ItemKind::Fn { ident, .. }
4574 | ItemKind::Macro(ident, ..)
4575 | ItemKind::Mod(ident, ..)
4576 | ItemKind::TyAlias(ident, ..)
4577 | ItemKind::Enum(ident, ..)
4578 | ItemKind::Struct(ident, ..)
4579 | ItemKind::Union(ident, ..)
4580 | ItemKind::Trait(_, _, _, ident, ..)
4581 | ItemKind::TraitAlias(_, ident, ..) => Some(ident),
4582
4583 ItemKind::Use(_, UseKind::Glob | UseKind::ListStem)
4584 | ItemKind::ForeignMod { .. }
4585 | ItemKind::GlobalAsm { .. }
4586 | ItemKind::Impl(_) => None,
4587 }
4588 }
4589
4590 pub fn generics(&self) -> Option<&Generics<'_>> {
4591 Some(match self {
4592 ItemKind::Fn { generics, .. }
4593 | ItemKind::TyAlias(_, generics, _)
4594 | ItemKind::Const(_, generics, _, _)
4595 | ItemKind::Enum(_, generics, _)
4596 | ItemKind::Struct(_, generics, _)
4597 | ItemKind::Union(_, generics, _)
4598 | ItemKind::Trait(_, _, _, _, generics, _, _)
4599 | ItemKind::TraitAlias(_, _, generics, _)
4600 | ItemKind::Impl(Impl { generics, .. }) => generics,
4601 _ => return None,
4602 })
4603 }
4604
4605 pub fn recovered(&self) -> bool {
4606 match self {
4607 ItemKind::Struct(
4608 _,
4609 _,
4610 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4611 ) => true,
4612 ItemKind::Union(
4613 _,
4614 _,
4615 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4616 ) => true,
4617 ItemKind::Enum(_, _, def) => def.variants.iter().any(|v| match v.data {
4618 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. } => true,
4619 _ => false,
4620 }),
4621 _ => false,
4622 }
4623 }
4624}
4625
4626#[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: ::rustc_span::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)]
4630pub struct ForeignItemId {
4631 pub owner_id: OwnerId,
4632}
4633
4634impl ForeignItemId {
4635 #[inline]
4636 pub fn hir_id(&self) -> HirId {
4637 HirId::make_owner(self.owner_id.def_id)
4639 }
4640}
4641
4642#[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: ::rustc_span::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)]
4643pub struct ForeignItem<'hir> {
4644 pub ident: Ident,
4645 pub kind: ForeignItemKind<'hir>,
4646 pub owner_id: OwnerId,
4647 pub span: Span,
4648 pub vis_span: Span,
4649 pub has_delayed_lints: bool,
4650}
4651
4652impl ForeignItem<'_> {
4653 #[inline]
4654 pub fn hir_id(&self) -> HirId {
4655 HirId::make_owner(self.owner_id.def_id)
4657 }
4658
4659 pub fn foreign_item_id(&self) -> ForeignItemId {
4660 ForeignItemId { owner_id: self.owner_id }
4661 }
4662}
4663
4664#[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: ::rustc_span::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)]
4666pub enum ForeignItemKind<'hir> {
4667 Fn(FnSig<'hir>, &'hir [Option<Ident>], &'hir Generics<'hir>),
4674 Static(&'hir Ty<'hir>, Mutability, Safety),
4676 Type,
4678}
4679
4680#[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: ::rustc_span::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)]
4682pub struct Upvar {
4683 pub span: Span,
4685}
4686
4687#[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: ::rustc_span::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)]
4691pub struct TraitCandidate<'hir> {
4692 pub def_id: DefId,
4693 pub import_ids: &'hir [LocalDefId],
4694 pub lint_ambiguous: bool,
4699}
4700
4701#[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: ::rustc_span::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)]
4702pub enum OwnerNode<'hir> {
4703 Item(&'hir Item<'hir>),
4704 ForeignItem(&'hir ForeignItem<'hir>),
4705 TraitItem(&'hir TraitItem<'hir>),
4706 ImplItem(&'hir ImplItem<'hir>),
4707 Crate(&'hir Mod<'hir>),
4708 Synthetic,
4709}
4710
4711impl<'hir> OwnerNode<'hir> {
4712 pub fn span(&self) -> Span {
4713 match self {
4714 OwnerNode::Item(Item { span, .. })
4715 | OwnerNode::ForeignItem(ForeignItem { span, .. })
4716 | OwnerNode::ImplItem(ImplItem { span, .. })
4717 | OwnerNode::TraitItem(TraitItem { span, .. }) => *span,
4718 OwnerNode::Crate(Mod { spans: ModSpans { inner_span, .. }, .. }) => *inner_span,
4719 OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4720 }
4721 }
4722
4723 pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
4724 match self {
4725 OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4726 | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4727 | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4728 | OwnerNode::ForeignItem(ForeignItem {
4729 kind: ForeignItemKind::Fn(fn_sig, _, _), ..
4730 }) => Some(fn_sig),
4731 _ => None,
4732 }
4733 }
4734
4735 pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
4736 match self {
4737 OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4738 | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4739 | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4740 | OwnerNode::ForeignItem(ForeignItem {
4741 kind: ForeignItemKind::Fn(fn_sig, _, _), ..
4742 }) => Some(fn_sig.decl),
4743 _ => None,
4744 }
4745 }
4746
4747 pub fn body_id(&self) -> Option<BodyId> {
4748 match self {
4749 OwnerNode::Item(Item {
4750 kind:
4751 ItemKind::Static(_, _, _, body)
4752 | ItemKind::Const(.., ConstItemRhs::Body(body))
4753 | ItemKind::Fn { body, .. },
4754 ..
4755 })
4756 | OwnerNode::TraitItem(TraitItem {
4757 kind:
4758 TraitItemKind::Fn(_, TraitFn::Provided(body))
4759 | TraitItemKind::Const(_, Some(ConstItemRhs::Body(body)), _),
4760 ..
4761 })
4762 | OwnerNode::ImplItem(ImplItem {
4763 kind: ImplItemKind::Fn(_, body) | ImplItemKind::Const(_, ConstItemRhs::Body(body)),
4764 ..
4765 }) => Some(*body),
4766 _ => None,
4767 }
4768 }
4769
4770 pub fn generics(self) -> Option<&'hir Generics<'hir>> {
4771 Node::generics(self.into())
4772 }
4773
4774 pub fn def_id(self) -> OwnerId {
4775 match self {
4776 OwnerNode::Item(Item { owner_id, .. })
4777 | OwnerNode::TraitItem(TraitItem { owner_id, .. })
4778 | OwnerNode::ImplItem(ImplItem { owner_id, .. })
4779 | OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
4780 OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
4781 OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4782 }
4783 }
4784
4785 pub fn is_impl_block(&self) -> bool {
4787 #[allow(non_exhaustive_omitted_patterns)] match self {
OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }) => true,
_ => false,
}matches!(self, OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }))
4788 }
4789
4790 self
let OwnerNode::TraitItem(n) =
self else { expect_failed("expect_trait_item", self) };
n;expect_methods_self! {
4791 expect_item, &'hir Item<'hir>, OwnerNode::Item(n), n;
4792 expect_foreign_item, &'hir ForeignItem<'hir>, OwnerNode::ForeignItem(n), n;
4793 expect_impl_item, &'hir ImplItem<'hir>, OwnerNode::ImplItem(n), n;
4794 expect_trait_item, &'hir TraitItem<'hir>, OwnerNode::TraitItem(n), n;
4795 }
4796}
4797
4798impl<'hir> From<&'hir Item<'hir>> for OwnerNode<'hir> {
4799 fn from(val: &'hir Item<'hir>) -> Self {
4800 OwnerNode::Item(val)
4801 }
4802}
4803
4804impl<'hir> From<&'hir ForeignItem<'hir>> for OwnerNode<'hir> {
4805 fn from(val: &'hir ForeignItem<'hir>) -> Self {
4806 OwnerNode::ForeignItem(val)
4807 }
4808}
4809
4810impl<'hir> From<&'hir ImplItem<'hir>> for OwnerNode<'hir> {
4811 fn from(val: &'hir ImplItem<'hir>) -> Self {
4812 OwnerNode::ImplItem(val)
4813 }
4814}
4815
4816impl<'hir> From<&'hir TraitItem<'hir>> for OwnerNode<'hir> {
4817 fn from(val: &'hir TraitItem<'hir>) -> Self {
4818 OwnerNode::TraitItem(val)
4819 }
4820}
4821
4822impl<'hir> From<OwnerNode<'hir>> for Node<'hir> {
4823 fn from(val: OwnerNode<'hir>) -> Self {
4824 match val {
4825 OwnerNode::Item(n) => Node::Item(n),
4826 OwnerNode::ForeignItem(n) => Node::ForeignItem(n),
4827 OwnerNode::ImplItem(n) => Node::ImplItem(n),
4828 OwnerNode::TraitItem(n) => Node::TraitItem(n),
4829 OwnerNode::Crate(n) => Node::Crate(n),
4830 OwnerNode::Synthetic => Node::Synthetic,
4831 }
4832 }
4833}
4834
4835#[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: ::rustc_span::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)]
4836pub enum Node<'hir> {
4837 Param(&'hir Param<'hir>),
4838 Item(&'hir Item<'hir>),
4839 ForeignItem(&'hir ForeignItem<'hir>),
4840 TraitItem(&'hir TraitItem<'hir>),
4841 ImplItem(&'hir ImplItem<'hir>),
4842 Variant(&'hir Variant<'hir>),
4843 Field(&'hir FieldDef<'hir>),
4844 AnonConst(&'hir AnonConst),
4845 ConstBlock(&'hir ConstBlock),
4846 ConstArg(&'hir ConstArg<'hir>),
4847 Expr(&'hir Expr<'hir>),
4848 ExprField(&'hir ExprField<'hir>),
4849 ConstArgExprField(&'hir ConstArgExprField<'hir>),
4850 Stmt(&'hir Stmt<'hir>),
4851 PathSegment(&'hir PathSegment<'hir>),
4852 Ty(&'hir Ty<'hir>),
4853 AssocItemConstraint(&'hir AssocItemConstraint<'hir>),
4854 TraitRef(&'hir TraitRef<'hir>),
4855 OpaqueTy(&'hir OpaqueTy<'hir>),
4856 TyPat(&'hir TyPat<'hir>),
4857 Pat(&'hir Pat<'hir>),
4858 PatField(&'hir PatField<'hir>),
4859 PatExpr(&'hir PatExpr<'hir>),
4863 Arm(&'hir Arm<'hir>),
4864 Block(&'hir Block<'hir>),
4865 LetStmt(&'hir LetStmt<'hir>),
4866 Ctor(&'hir VariantData<'hir>),
4869 Lifetime(&'hir Lifetime),
4870 GenericParam(&'hir GenericParam<'hir>),
4871 Crate(&'hir Mod<'hir>),
4872 Infer(&'hir InferArg),
4873 WherePredicate(&'hir WherePredicate<'hir>),
4874 PreciseCapturingNonLifetimeArg(&'hir PreciseCapturingNonLifetimeArg),
4875 Synthetic,
4877 Err(Span),
4878}
4879
4880impl<'hir> Node<'hir> {
4881 pub fn ident(&self) -> Option<Ident> {
4896 match self {
4897 Node::Item(item) => item.kind.ident(),
4898 Node::TraitItem(TraitItem { ident, .. })
4899 | Node::ImplItem(ImplItem { ident, .. })
4900 | Node::ForeignItem(ForeignItem { ident, .. })
4901 | Node::Field(FieldDef { ident, .. })
4902 | Node::Variant(Variant { ident, .. })
4903 | Node::PathSegment(PathSegment { ident, .. }) => Some(*ident),
4904 Node::Lifetime(lt) => Some(lt.ident),
4905 Node::GenericParam(p) => Some(p.name.ident()),
4906 Node::AssocItemConstraint(c) => Some(c.ident),
4907 Node::PatField(f) => Some(f.ident),
4908 Node::ExprField(f) => Some(f.ident),
4909 Node::ConstArgExprField(f) => Some(f.field),
4910 Node::PreciseCapturingNonLifetimeArg(a) => Some(a.ident),
4911 Node::Param(..)
4912 | Node::AnonConst(..)
4913 | Node::ConstBlock(..)
4914 | Node::ConstArg(..)
4915 | Node::Expr(..)
4916 | Node::Stmt(..)
4917 | Node::Block(..)
4918 | Node::Ctor(..)
4919 | Node::Pat(..)
4920 | Node::TyPat(..)
4921 | Node::PatExpr(..)
4922 | Node::Arm(..)
4923 | Node::LetStmt(..)
4924 | Node::Crate(..)
4925 | Node::Ty(..)
4926 | Node::TraitRef(..)
4927 | Node::OpaqueTy(..)
4928 | Node::Infer(..)
4929 | Node::WherePredicate(..)
4930 | Node::Synthetic
4931 | Node::Err(..) => None,
4932 }
4933 }
4934
4935 pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
4936 match self {
4937 Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4938 | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4939 | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4940 | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
4941 Some(fn_sig.decl)
4942 }
4943 Node::Expr(Expr { kind: ExprKind::Closure(Closure { fn_decl, .. }), .. }) => {
4944 Some(fn_decl)
4945 }
4946 _ => None,
4947 }
4948 }
4949
4950 pub fn impl_block_of_trait(self, trait_def_id: DefId) -> Option<&'hir Impl<'hir>> {
4952 if let Node::Item(Item { kind: ItemKind::Impl(impl_block), .. }) = self
4953 && let Some(of_trait) = impl_block.of_trait
4954 && let Some(trait_id) = of_trait.trait_ref.trait_def_id()
4955 && trait_id == trait_def_id
4956 {
4957 Some(impl_block)
4958 } else {
4959 None
4960 }
4961 }
4962
4963 pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
4964 match self {
4965 Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4966 | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4967 | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4968 | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
4969 Some(fn_sig)
4970 }
4971 _ => None,
4972 }
4973 }
4974
4975 pub fn ty(self) -> Option<&'hir Ty<'hir>> {
4977 match self {
4978 Node::Item(it) => match it.kind {
4979 ItemKind::TyAlias(_, _, ty)
4980 | ItemKind::Static(_, _, ty, _)
4981 | ItemKind::Const(_, _, ty, _) => Some(ty),
4982 ItemKind::Impl(impl_item) => Some(&impl_item.self_ty),
4983 _ => None,
4984 },
4985 Node::TraitItem(it) => match it.kind {
4986 TraitItemKind::Const(ty, _, _) => Some(ty),
4987 TraitItemKind::Type(_, ty) => ty,
4988 _ => None,
4989 },
4990 Node::ImplItem(it) => match it.kind {
4991 ImplItemKind::Const(ty, _) => Some(ty),
4992 ImplItemKind::Type(ty) => Some(ty),
4993 _ => None,
4994 },
4995 Node::ForeignItem(it) => match it.kind {
4996 ForeignItemKind::Static(ty, ..) => Some(ty),
4997 _ => None,
4998 },
4999 Node::GenericParam(param) => match param.kind {
5000 GenericParamKind::Lifetime { .. } => None,
5001 GenericParamKind::Type { default, .. } => default,
5002 GenericParamKind::Const { ty, .. } => Some(ty),
5003 },
5004 _ => None,
5005 }
5006 }
5007
5008 pub fn alias_ty(self) -> Option<&'hir Ty<'hir>> {
5009 match self {
5010 Node::Item(Item { kind: ItemKind::TyAlias(_, _, ty), .. }) => Some(ty),
5011 _ => None,
5012 }
5013 }
5014
5015 #[inline]
5016 pub fn associated_body(&self) -> Option<(LocalDefId, BodyId)> {
5017 match self {
5018 Node::Item(Item {
5019 owner_id,
5020 kind:
5021 ItemKind::Const(.., ConstItemRhs::Body(body))
5022 | ItemKind::Static(.., body)
5023 | ItemKind::Fn { body, .. },
5024 ..
5025 })
5026 | Node::TraitItem(TraitItem {
5027 owner_id,
5028 kind:
5029 TraitItemKind::Const(_, Some(ConstItemRhs::Body(body)), _)
5030 | TraitItemKind::Fn(_, TraitFn::Provided(body)),
5031 ..
5032 })
5033 | Node::ImplItem(ImplItem {
5034 owner_id,
5035 kind: ImplItemKind::Const(.., ConstItemRhs::Body(body)) | ImplItemKind::Fn(_, body),
5036 ..
5037 }) => Some((owner_id.def_id, *body)),
5038
5039 Node::Item(Item {
5040 owner_id, kind: ItemKind::GlobalAsm { asm: _, fake_body }, ..
5041 }) => Some((owner_id.def_id, *fake_body)),
5042
5043 Node::Expr(Expr { kind: ExprKind::Closure(Closure { def_id, body, .. }), .. }) => {
5044 Some((*def_id, *body))
5045 }
5046
5047 Node::AnonConst(constant) => Some((constant.def_id, constant.body)),
5048 Node::ConstBlock(constant) => Some((constant.def_id, constant.body)),
5049
5050 _ => None,
5051 }
5052 }
5053
5054 pub fn body_id(&self) -> Option<BodyId> {
5055 Some(self.associated_body()?.1)
5056 }
5057
5058 pub fn generics(self) -> Option<&'hir Generics<'hir>> {
5059 match self {
5060 Node::ForeignItem(ForeignItem {
5061 kind: ForeignItemKind::Fn(_, _, generics), ..
5062 })
5063 | Node::TraitItem(TraitItem { generics, .. })
5064 | Node::ImplItem(ImplItem { generics, .. }) => Some(generics),
5065 Node::Item(item) => item.kind.generics(),
5066 _ => None,
5067 }
5068 }
5069
5070 pub fn as_owner(self) -> Option<OwnerNode<'hir>> {
5071 match self {
5072 Node::Item(i) => Some(OwnerNode::Item(i)),
5073 Node::ForeignItem(i) => Some(OwnerNode::ForeignItem(i)),
5074 Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
5075 Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
5076 Node::Crate(i) => Some(OwnerNode::Crate(i)),
5077 Node::Synthetic => Some(OwnerNode::Synthetic),
5078 _ => None,
5079 }
5080 }
5081
5082 pub fn fn_kind(self) -> Option<FnKind<'hir>> {
5083 match self {
5084 Node::Item(i) => match i.kind {
5085 ItemKind::Fn { ident, sig, generics, .. } => {
5086 Some(FnKind::ItemFn(ident, generics, sig.header))
5087 }
5088 _ => None,
5089 },
5090 Node::TraitItem(ti) => match ti.kind {
5091 TraitItemKind::Fn(ref sig, _) => Some(FnKind::Method(ti.ident, sig)),
5092 _ => None,
5093 },
5094 Node::ImplItem(ii) => match ii.kind {
5095 ImplItemKind::Fn(ref sig, _) => Some(FnKind::Method(ii.ident, sig)),
5096 _ => None,
5097 },
5098 Node::Expr(e) => match e.kind {
5099 ExprKind::Closure { .. } => Some(FnKind::Closure),
5100 _ => None,
5101 },
5102 _ => None,
5103 }
5104 }
5105
5106 self
let Node::Expr(Expr { kind: ExprKind::Closure(n), .. }) =
self else { expect_failed("expect_closure", self) };
n;expect_methods_self! {
5107 expect_param, &'hir Param<'hir>, Node::Param(n), n;
5108 expect_item, &'hir Item<'hir>, Node::Item(n), n;
5109 expect_foreign_item, &'hir ForeignItem<'hir>, Node::ForeignItem(n), n;
5110 expect_trait_item, &'hir TraitItem<'hir>, Node::TraitItem(n), n;
5111 expect_impl_item, &'hir ImplItem<'hir>, Node::ImplItem(n), n;
5112 expect_variant, &'hir Variant<'hir>, Node::Variant(n), n;
5113 expect_field, &'hir FieldDef<'hir>, Node::Field(n), n;
5114 expect_anon_const, &'hir AnonConst, Node::AnonConst(n), n;
5115 expect_inline_const, &'hir ConstBlock, Node::ConstBlock(n), n;
5116 expect_expr, &'hir Expr<'hir>, Node::Expr(n), n;
5117 expect_expr_field, &'hir ExprField<'hir>, Node::ExprField(n), n;
5118 expect_stmt, &'hir Stmt<'hir>, Node::Stmt(n), n;
5119 expect_path_segment, &'hir PathSegment<'hir>, Node::PathSegment(n), n;
5120 expect_ty, &'hir Ty<'hir>, Node::Ty(n), n;
5121 expect_assoc_item_constraint, &'hir AssocItemConstraint<'hir>, Node::AssocItemConstraint(n), n;
5122 expect_trait_ref, &'hir TraitRef<'hir>, Node::TraitRef(n), n;
5123 expect_opaque_ty, &'hir OpaqueTy<'hir>, Node::OpaqueTy(n), n;
5124 expect_pat, &'hir Pat<'hir>, Node::Pat(n), n;
5125 expect_pat_field, &'hir PatField<'hir>, Node::PatField(n), n;
5126 expect_arm, &'hir Arm<'hir>, Node::Arm(n), n;
5127 expect_block, &'hir Block<'hir>, Node::Block(n), n;
5128 expect_let_stmt, &'hir LetStmt<'hir>, Node::LetStmt(n), n;
5129 expect_ctor, &'hir VariantData<'hir>, Node::Ctor(n), n;
5130 expect_lifetime, &'hir Lifetime, Node::Lifetime(n), n;
5131 expect_generic_param, &'hir GenericParam<'hir>, Node::GenericParam(n), n;
5132 expect_crate, &'hir Mod<'hir>, Node::Crate(n), n;
5133 expect_infer, &'hir InferArg, Node::Infer(n), n;
5134 expect_closure, &'hir Closure<'hir>, Node::Expr(Expr { kind: ExprKind::Closure(n), .. }), n;
5135 }
5136}
5137
5138#[cfg(target_pointer_width = "64")]
5140mod size_asserts {
5141 use rustc_data_structures::static_assert_size;
5142
5143 use super::*;
5144 const _: [(); 48] = [(); ::std::mem::size_of::<Block<'_>>()];static_assert_size!(Block<'_>, 48);
5146 const _: [(); 24] = [(); ::std::mem::size_of::<Body<'_>>()];static_assert_size!(Body<'_>, 24);
5147 const _: [(); 64] = [(); ::std::mem::size_of::<Expr<'_>>()];static_assert_size!(Expr<'_>, 64);
5148 const _: [(); 48] = [(); ::std::mem::size_of::<ExprKind<'_>>()];static_assert_size!(ExprKind<'_>, 48);
5149 const _: [(); 40] = [(); ::std::mem::size_of::<FnDecl<'_>>()];static_assert_size!(FnDecl<'_>, 40);
5150 const _: [(); 96] = [(); ::std::mem::size_of::<ForeignItem<'_>>()];static_assert_size!(ForeignItem<'_>, 96);
5151 const _: [(); 56] = [(); ::std::mem::size_of::<ForeignItemKind<'_>>()];static_assert_size!(ForeignItemKind<'_>, 56);
5152 const _: [(); 16] = [(); ::std::mem::size_of::<GenericArg<'_>>()];static_assert_size!(GenericArg<'_>, 16);
5153 const _: [(); 64] = [(); ::std::mem::size_of::<GenericBound<'_>>()];static_assert_size!(GenericBound<'_>, 64);
5154 const _: [(); 56] = [(); ::std::mem::size_of::<Generics<'_>>()];static_assert_size!(Generics<'_>, 56);
5155 const _: [(); 48] = [(); ::std::mem::size_of::<Impl<'_>>()];static_assert_size!(Impl<'_>, 48);
5156 const _: [(); 88] = [(); ::std::mem::size_of::<ImplItem<'_>>()];static_assert_size!(ImplItem<'_>, 88);
5157 const _: [(); 40] = [(); ::std::mem::size_of::<ImplItemKind<'_>>()];static_assert_size!(ImplItemKind<'_>, 40);
5158 const _: [(); 88] = [(); ::std::mem::size_of::<Item<'_>>()];static_assert_size!(Item<'_>, 88);
5159 const _: [(); 64] = [(); ::std::mem::size_of::<ItemKind<'_>>()];static_assert_size!(ItemKind<'_>, 64);
5160 const _: [(); 64] = [(); ::std::mem::size_of::<LetStmt<'_>>()];static_assert_size!(LetStmt<'_>, 64);
5161 const _: [(); 32] = [(); ::std::mem::size_of::<Param<'_>>()];static_assert_size!(Param<'_>, 32);
5162 const _: [(); 80] = [(); ::std::mem::size_of::<Pat<'_>>()];static_assert_size!(Pat<'_>, 80);
5163 const _: [(); 56] = [(); ::std::mem::size_of::<PatKind<'_>>()];static_assert_size!(PatKind<'_>, 56);
5164 const _: [(); 40] = [(); ::std::mem::size_of::<Path<'_>>()];static_assert_size!(Path<'_>, 40);
5165 const _: [(); 48] = [(); ::std::mem::size_of::<PathSegment<'_>>()];static_assert_size!(PathSegment<'_>, 48);
5166 const _: [(); 24] = [(); ::std::mem::size_of::<QPath<'_>>()];static_assert_size!(QPath<'_>, 24);
5167 const _: [(); 12] = [(); ::std::mem::size_of::<Res>()];static_assert_size!(Res, 12);
5168 const _: [(); 32] = [(); ::std::mem::size_of::<Stmt<'_>>()];static_assert_size!(Stmt<'_>, 32);
5169 const _: [(); 16] = [(); ::std::mem::size_of::<StmtKind<'_>>()];static_assert_size!(StmtKind<'_>, 16);
5170 const _: [(); 48] = [(); ::std::mem::size_of::<TraitImplHeader<'_>>()];static_assert_size!(TraitImplHeader<'_>, 48);
5171 const _: [(); 88] = [(); ::std::mem::size_of::<TraitItem<'_>>()];static_assert_size!(TraitItem<'_>, 88);
5172 const _: [(); 48] = [(); ::std::mem::size_of::<TraitItemKind<'_>>()];static_assert_size!(TraitItemKind<'_>, 48);
5173 const _: [(); 48] = [(); ::std::mem::size_of::<Ty<'_>>()];static_assert_size!(Ty<'_>, 48);
5174 const _: [(); 32] = [(); ::std::mem::size_of::<TyKind<'_>>()];static_assert_size!(TyKind<'_>, 32);
5175 }
5177
5178#[cfg(test)]
5179mod tests;