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::source_map::Spanned;
27use rustc_span::{
28 BytePos, DUMMY_SP, DesugaringKind, ErrorGuaranteed, Ident, Span, Symbol, kw, sym,
29};
30use rustc_target::asm::InlineAsmRegOrRegClass;
31use smallvec::SmallVec;
32use thin_vec::ThinVec;
33use tracing::debug;
34
35use crate::attrs::AttributeKind;
36use crate::def::{CtorKind, DefKind, MacroKinds, PerNS, Res};
37use crate::def_id::{DefId, LocalDefIdMap};
38pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId};
39use crate::intravisit::{FnKind, VisitorExt};
40use crate::lints::DelayedLints;
41
42#[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_receiver_is_total_eq(&self) {}
}Eq, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AngleBrackets where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
AngleBrackets::Missing => {}
AngleBrackets::Empty => {}
AngleBrackets::Full => {}
}
}
}
};HashStable_Generic)]
43pub enum AngleBrackets {
44 Missing,
46 Empty,
48 Full,
50}
51
52#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<AngleBrackets>;
}
}Eq, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LifetimeSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LifetimeSource::Reference => {}
LifetimeSource::Path { angle_brackets: ref __binding_0 } =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
}
LifetimeSource::OutlivesBound => {}
LifetimeSource::PreciseCapturing => {}
LifetimeSource::Other => {}
}
}
}
};HashStable_Generic)]
53pub enum LifetimeSource {
54 Reference,
56
57 Path { angle_brackets: AngleBrackets },
60
61 OutlivesBound,
63
64 PreciseCapturing,
66
67 Other,
74}
75
76#[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_receiver_is_total_eq(&self) {}
}Eq, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LifetimeSyntax where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LifetimeSyntax::Implicit => {}
LifetimeSyntax::ExplicitAnonymous => {}
LifetimeSyntax::ExplicitBound => {}
}
}
}
};HashStable_Generic)]
77pub enum LifetimeSyntax {
78 Implicit,
80
81 ExplicitAnonymous,
83
84 ExplicitBound,
86}
87
88impl From<Ident> for LifetimeSyntax {
89 fn from(ident: Ident) -> Self {
90 let name = ident.name;
91
92 if name == sym::empty {
93 {
::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");
94 } else if name == kw::UnderscoreLifetime {
95 LifetimeSyntax::ExplicitAnonymous
96 } else {
97 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('\''));
98 LifetimeSyntax::ExplicitBound
99 }
100 }
101}
102
103#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Lifetime {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Lifetime",
"hir_id", &self.hir_id, "ident", &self.ident, "kind", &self.kind,
"source", &self.source, "syntax", &&self.syntax)
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Lifetime { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Lifetime {
#[inline]
fn clone(&self) -> Lifetime {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<LifetimeKind>;
let _: ::core::clone::AssertParamIsClone<LifetimeSource>;
let _: ::core::clone::AssertParamIsClone<LifetimeSyntax>;
*self
}
}Clone, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Lifetime where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Lifetime {
hir_id: ref __binding_0,
ident: ref __binding_1,
kind: ref __binding_2,
source: ref __binding_3,
syntax: ref __binding_4 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
154#[repr(align(4))]
162pub struct Lifetime {
163 #[stable_hasher(ignore)]
164 pub hir_id: HirId,
165
166 pub ident: Ident,
170
171 pub kind: LifetimeKind,
173
174 pub source: LifetimeSource,
177
178 pub syntax: LifetimeSyntax,
181}
182
183#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ParamName {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ParamName::Plain(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Plain",
&__self_0),
ParamName::Error(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Error",
&__self_0),
ParamName::Fresh => ::core::fmt::Formatter::write_str(f, "Fresh"),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for ParamName { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ParamName {
#[inline]
fn clone(&self) -> ParamName {
let _: ::core::clone::AssertParamIsClone<Ident>;
*self
}
}Clone, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ParamName where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ParamName::Plain(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ParamName::Error(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ParamName::Fresh => {}
}
}
}
};HashStable_Generic)]
184pub enum ParamName {
185 Plain(Ident),
187
188 Error(Ident),
194
195 Fresh,
210}
211
212impl ParamName {
213 pub fn ident(&self) -> Ident {
214 match *self {
215 ParamName::Plain(ident) | ParamName::Error(ident) => ident,
216 ParamName::Fresh => Ident::with_dummy_span(kw::UnderscoreLifetime),
217 }
218 }
219}
220
221#[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 =>
::core::fmt::Formatter::write_str(f, "Error"),
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>;
*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,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LifetimeKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<LocalDefId>;
}
}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),
_ => {}
}
}
}Hash, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LifetimeKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LifetimeKind::Param(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
LifetimeKind::ImplicitObjectLifetimeDefault => {}
LifetimeKind::Error => {}
LifetimeKind::Infer => {}
LifetimeKind::Static => {}
}
}
}
};HashStable_Generic)]
222pub enum LifetimeKind {
223 Param(LocalDefId),
225
226 ImplicitObjectLifetimeDefault,
238
239 Error,
242
243 Infer,
247
248 Static,
250}
251
252impl LifetimeKind {
253 fn is_elided(&self) -> bool {
254 match self {
255 LifetimeKind::ImplicitObjectLifetimeDefault | LifetimeKind::Infer => true,
256
257 LifetimeKind::Error | LifetimeKind::Param(..) | LifetimeKind::Static => false,
262 }
263 }
264}
265
266impl fmt::Display for Lifetime {
267 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
268 self.ident.name.fmt(f)
269 }
270}
271
272impl Lifetime {
273 pub fn new(
274 hir_id: HirId,
275 ident: Ident,
276 kind: LifetimeKind,
277 source: LifetimeSource,
278 syntax: LifetimeSyntax,
279 ) -> Lifetime {
280 let lifetime = Lifetime { hir_id, ident, kind, source, syntax };
281
282 #[cfg(debug_assertions)]
284 match (lifetime.is_elided(), lifetime.is_anonymous()) {
285 (false, false) => {} (false, true) => {} (true, true) => {} (true, false) => { ::core::panicking::panic_fmt(format_args!("bad Lifetime")); }panic!("bad Lifetime"),
289 }
290
291 lifetime
292 }
293
294 pub fn is_elided(&self) -> bool {
295 self.kind.is_elided()
296 }
297
298 pub fn is_anonymous(&self) -> bool {
299 self.ident.name == kw::UnderscoreLifetime
300 }
301
302 pub fn is_implicit(&self) -> bool {
303 #[allow(non_exhaustive_omitted_patterns)] match self.syntax {
LifetimeSyntax::Implicit => true,
_ => false,
}matches!(self.syntax, LifetimeSyntax::Implicit)
304 }
305
306 pub fn is_static(&self) -> bool {
307 self.kind == LifetimeKind::Static
308 }
309
310 pub fn suggestion(&self, new_lifetime: &str) -> (Span, String) {
311 use LifetimeSource::*;
312 use LifetimeSyntax::*;
313
314 if true {
if !new_lifetime.starts_with('\'') {
::core::panicking::panic("assertion failed: new_lifetime.starts_with(\'\\\'\')")
};
};debug_assert!(new_lifetime.starts_with('\''));
315
316 match (self.syntax, self.source) {
317 (ExplicitBound | ExplicitAnonymous, _) => (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", new_lifetime))
})format!("{new_lifetime}")),
319
320 (Implicit, Path { angle_brackets: AngleBrackets::Full }) => {
322 (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}, ", new_lifetime))
})format!("{new_lifetime}, "))
323 }
324
325 (Implicit, Path { angle_brackets: AngleBrackets::Empty }) => {
327 (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", new_lifetime))
})format!("{new_lifetime}"))
328 }
329
330 (Implicit, Path { angle_brackets: AngleBrackets::Missing }) => {
332 (self.ident.span.shrink_to_hi(), ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<{0}>", new_lifetime))
})format!("<{new_lifetime}>"))
333 }
334
335 (Implicit, Reference) => (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", new_lifetime))
})format!("{new_lifetime} ")),
337
338 (Implicit, source) => {
339 {
::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:?}")
340 }
341 }
342 }
343}
344
345#[derive(#[automatically_derived]
impl<'hir, R: ::core::fmt::Debug> ::core::fmt::Debug for Path<'hir, R> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "Path", "span",
&self.span, "res", &self.res, "segments", &&self.segments)
}
}Debug, #[automatically_derived]
impl<'hir, R: ::core::clone::Clone> ::core::clone::Clone for Path<'hir, R> {
#[inline]
fn clone(&self) -> Path<'hir, R> {
Path {
span: ::core::clone::Clone::clone(&self.span),
res: ::core::clone::Clone::clone(&self.res),
segments: ::core::clone::Clone::clone(&self.segments),
}
}
}Clone, #[automatically_derived]
impl<'hir, R: ::core::marker::Copy> ::core::marker::Copy for Path<'hir, R> { }Copy, const _: () =
{
impl<'hir, R, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Path<'hir, R> where __CTX: crate::HashStableContext,
R: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Path {
span: ref __binding_0,
res: ref __binding_1,
segments: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
349pub struct Path<'hir, R = Res> {
350 pub span: Span,
351 pub res: R,
353 pub segments: &'hir [PathSegment<'hir>],
355}
356
357pub type UsePath<'hir> = Path<'hir, PerNS<Option<Res>>>;
359
360impl Path<'_> {
361 pub fn is_global(&self) -> bool {
362 self.segments.first().is_some_and(|segment| segment.ident.name == kw::PathRoot)
363 }
364}
365
366#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PathSegment<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "PathSegment",
"ident", &self.ident, "hir_id", &self.hir_id, "res", &self.res,
"args", &self.args, "infer_args", &&self.infer_args)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PathSegment<'hir> {
#[inline]
fn clone(&self) -> PathSegment<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Res>;
let _:
::core::clone::AssertParamIsClone<Option<&'hir GenericArgs<'hir>>>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PathSegment<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PathSegment<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
PathSegment {
ident: ref __binding_0,
hir_id: ref __binding_1,
res: ref __binding_2,
args: ref __binding_3,
infer_args: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{}
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
369pub struct PathSegment<'hir> {
370 pub ident: Ident,
372 #[stable_hasher(ignore)]
373 pub hir_id: HirId,
374 pub res: Res,
375
376 pub args: Option<&'hir GenericArgs<'hir>>,
382
383 pub infer_args: bool,
388}
389
390impl<'hir> PathSegment<'hir> {
391 pub fn new(ident: Ident, hir_id: HirId, res: Res) -> PathSegment<'hir> {
393 PathSegment { ident, hir_id, res, infer_args: true, args: None }
394 }
395
396 pub fn invalid() -> Self {
397 Self::new(Ident::dummy(), HirId::INVALID, Res::Err)
398 }
399
400 pub fn args(&self) -> &GenericArgs<'hir> {
401 if let Some(ref args) = self.args {
402 args
403 } else {
404 const DUMMY: &GenericArgs<'_> = &GenericArgs::none();
405 DUMMY
406 }
407 }
408}
409
410#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for ConstItemRhs<'hir> {
#[inline]
fn clone(&self) -> ConstItemRhs<'hir> {
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ConstItemRhs<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for ConstItemRhs<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ConstItemRhs::Body(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Body",
&__self_0),
ConstItemRhs::TypeConst(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TypeConst", &__self_0),
}
}
}Debug, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstItemRhs<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ConstItemRhs::Body(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstItemRhs::TypeConst(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
411pub enum ConstItemRhs<'hir> {
412 Body(BodyId),
413 TypeConst(&'hir ConstArg<'hir>),
414}
415
416impl<'hir> ConstItemRhs<'hir> {
417 pub fn hir_id(&self) -> HirId {
418 match self {
419 ConstItemRhs::Body(body_id) => body_id.hir_id,
420 ConstItemRhs::TypeConst(ct_arg) => ct_arg.hir_id,
421 }
422 }
423
424 pub fn span<'tcx>(&self, tcx: impl crate::intravisit::HirTyCtxt<'tcx>) -> Span {
425 match self {
426 ConstItemRhs::Body(body_id) => tcx.hir_body(*body_id).value.span,
427 ConstItemRhs::TypeConst(ct_arg) => ct_arg.span,
428 }
429 }
430}
431
432#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
ConstArg<'hir, Unambig> {
#[inline]
fn clone(&self) -> ConstArg<'hir, Unambig> {
ConstArg {
hir_id: ::core::clone::Clone::clone(&self.hir_id),
kind: ::core::clone::Clone::clone(&self.kind),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
ConstArg<'hir, Unambig> {
}Copy, #[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
ConstArg<'hir, Unambig> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "ConstArg",
"hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
}
}Debug, const _: () =
{
impl<'hir, Unambig, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstArg<'hir, Unambig> where __CTX: crate::HashStableContext,
Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ConstArg {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
446#[repr(C)]
447pub struct ConstArg<'hir, Unambig = ()> {
448 #[stable_hasher(ignore)]
449 pub hir_id: HirId,
450 pub kind: ConstArgKind<'hir, Unambig>,
451 pub span: Span,
452}
453
454impl<'hir> ConstArg<'hir, AmbigArg> {
455 pub fn as_unambig_ct(&self) -> &ConstArg<'hir> {
466 let ptr = self as *const ConstArg<'hir, AmbigArg> as *const ConstArg<'hir, ()>;
469 unsafe { &*ptr }
470 }
471}
472
473impl<'hir> ConstArg<'hir> {
474 pub fn try_as_ambig_ct(&self) -> Option<&ConstArg<'hir, AmbigArg>> {
480 if let ConstArgKind::Infer(()) = self.kind {
481 return None;
482 }
483
484 let ptr = self as *const ConstArg<'hir> as *const ConstArg<'hir, AmbigArg>;
488 Some(unsafe { &*ptr })
489 }
490}
491
492impl<'hir, Unambig> ConstArg<'hir, Unambig> {
493 pub fn anon_const_hir_id(&self) -> Option<HirId> {
494 match self.kind {
495 ConstArgKind::Anon(ac) => Some(ac.hir_id),
496 _ => None,
497 }
498 }
499}
500
501#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
ConstArgKind<'hir, Unambig> {
#[inline]
fn clone(&self) -> ConstArgKind<'hir, Unambig> {
match self {
ConstArgKind::Tup(__self_0) =>
ConstArgKind::Tup(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Path(__self_0) =>
ConstArgKind::Path(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Anon(__self_0) =>
ConstArgKind::Anon(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Struct(__self_0, __self_1) =>
ConstArgKind::Struct(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
ConstArgKind::TupleCall(__self_0, __self_1) =>
ConstArgKind::TupleCall(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
ConstArgKind::Array(__self_0) =>
ConstArgKind::Array(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Error(__self_0) =>
ConstArgKind::Error(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Infer(__self_0) =>
ConstArgKind::Infer(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Literal { lit: __self_0, negated: __self_1 } =>
ConstArgKind::Literal {
lit: ::core::clone::Clone::clone(__self_0),
negated: ::core::clone::Clone::clone(__self_1),
},
}
}
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
ConstArgKind<'hir, Unambig> {
}Copy, #[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
ConstArgKind<'hir, Unambig> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ConstArgKind::Tup(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tup",
&__self_0),
ConstArgKind::Path(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
&__self_0),
ConstArgKind::Anon(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Anon",
&__self_0),
ConstArgKind::Struct(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Struct",
__self_0, &__self_1),
ConstArgKind::TupleCall(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"TupleCall", __self_0, &__self_1),
ConstArgKind::Array(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Array",
&__self_0),
ConstArgKind::Error(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Error",
&__self_0),
ConstArgKind::Infer(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
&__self_0),
ConstArgKind::Literal { lit: __self_0, negated: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"Literal", "lit", __self_0, "negated", &__self_1),
}
}
}Debug, const _: () =
{
impl<'hir, Unambig, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstArgKind<'hir, Unambig> where __CTX: crate::HashStableContext,
Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ConstArgKind::Tup(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Path(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Anon(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Struct(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ConstArgKind::TupleCall(ref __binding_0, ref __binding_1) =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Array(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Error(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Infer(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstArgKind::Literal {
lit: ref __binding_0, negated: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
503#[repr(u8, C)]
504pub enum ConstArgKind<'hir, Unambig = ()> {
505 Tup(&'hir [&'hir ConstArg<'hir, Unambig>]),
506 Path(QPath<'hir>),
512 Anon(&'hir AnonConst),
513 Struct(QPath<'hir>, &'hir [&'hir ConstArgExprField<'hir>]),
515 TupleCall(QPath<'hir>, &'hir [&'hir ConstArg<'hir>]),
517 Array(&'hir ConstArgArrayExpr<'hir>),
519 Error(ErrorGuaranteed),
521 Infer(Unambig),
524 Literal {
525 lit: LitKind,
526 negated: bool,
527 },
528}
529
530#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for ConstArgExprField<'hir> {
#[inline]
fn clone(&self) -> ConstArgExprField<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ConstArgExprField<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for ConstArgExprField<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"ConstArgExprField", "hir_id", &self.hir_id, "span", &self.span,
"field", &self.field, "expr", &&self.expr)
}
}Debug, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstArgExprField<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ConstArgExprField {
hir_id: ref __binding_0,
span: ref __binding_1,
field: ref __binding_2,
expr: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
531pub struct ConstArgExprField<'hir> {
532 pub hir_id: HirId,
533 pub span: Span,
534 pub field: Ident,
535 pub expr: &'hir ConstArg<'hir>,
536}
537
538#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for ConstArgArrayExpr<'hir> {
#[inline]
fn clone(&self) -> ConstArgArrayExpr<'hir> {
let _: ::core::clone::AssertParamIsClone<Span>;
let _:
::core::clone::AssertParamIsClone<&'hir [&'hir ConstArg<'hir>]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ConstArgArrayExpr<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for ConstArgArrayExpr<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"ConstArgArrayExpr", "span", &self.span, "elems", &&self.elems)
}
}Debug, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstArgArrayExpr<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ConstArgArrayExpr {
span: ref __binding_0, elems: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
539pub struct ConstArgArrayExpr<'hir> {
540 pub span: Span,
541 pub elems: &'hir [&'hir ConstArg<'hir>],
542}
543
544#[derive(#[automatically_derived]
impl ::core::clone::Clone for InferArg {
#[inline]
fn clone(&self) -> InferArg {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InferArg { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for InferArg {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "InferArg",
"hir_id", &self.hir_id, "span", &&self.span)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for InferArg where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
InferArg { hir_id: ref __binding_0, span: ref __binding_1 }
=> {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
545pub struct InferArg {
546 #[stable_hasher(ignore)]
547 pub hir_id: HirId,
548 pub span: Span,
549}
550
551impl InferArg {
552 pub fn to_ty(&self) -> Ty<'static> {
553 Ty { kind: TyKind::Infer(()), span: self.span, hir_id: self.hir_id }
554 }
555}
556
557#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericArg<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
GenericArg::Lifetime(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Lifetime", &__self_0),
GenericArg::Type(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Type",
&__self_0),
GenericArg::Const(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
&__self_0),
GenericArg::Infer(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericArg<'hir> {
#[inline]
fn clone(&self) -> GenericArg<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir, AmbigArg>>;
let _:
::core::clone::AssertParamIsClone<&'hir ConstArg<'hir,
AmbigArg>>;
let _: ::core::clone::AssertParamIsClone<InferArg>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericArg<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericArg<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericArg::Lifetime(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericArg::Type(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericArg::Const(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericArg::Infer(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
558pub enum GenericArg<'hir> {
559 Lifetime(&'hir Lifetime),
560 Type(&'hir Ty<'hir, AmbigArg>),
561 Const(&'hir ConstArg<'hir, AmbigArg>),
562 Infer(InferArg),
572}
573
574impl GenericArg<'_> {
575 pub fn span(&self) -> Span {
576 match self {
577 GenericArg::Lifetime(l) => l.ident.span,
578 GenericArg::Type(t) => t.span,
579 GenericArg::Const(c) => c.span,
580 GenericArg::Infer(i) => i.span,
581 }
582 }
583
584 pub fn hir_id(&self) -> HirId {
585 match self {
586 GenericArg::Lifetime(l) => l.hir_id,
587 GenericArg::Type(t) => t.hir_id,
588 GenericArg::Const(c) => c.hir_id,
589 GenericArg::Infer(i) => i.hir_id,
590 }
591 }
592
593 pub fn descr(&self) -> &'static str {
594 match self {
595 GenericArg::Lifetime(_) => "lifetime",
596 GenericArg::Type(_) => "type",
597 GenericArg::Const(_) => "constant",
598 GenericArg::Infer(_) => "placeholder",
599 }
600 }
601
602 pub fn to_ord(&self) -> ast::ParamKindOrd {
603 match self {
604 GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime,
605 GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => {
606 ast::ParamKindOrd::TypeOrConst
607 }
608 }
609 }
610
611 pub fn is_ty_or_const(&self) -> bool {
612 match self {
613 GenericArg::Lifetime(_) => false,
614 GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => true,
615 }
616 }
617}
618
619#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericArgs<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "GenericArgs",
"args", &self.args, "constraints", &self.constraints,
"parenthesized", &self.parenthesized, "span_ext", &&self.span_ext)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericArgs<'hir> {
#[inline]
fn clone(&self) -> GenericArgs<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [GenericArg<'hir>]>;
let _:
::core::clone::AssertParamIsClone<&'hir [AssocItemConstraint<'hir>]>;
let _: ::core::clone::AssertParamIsClone<GenericArgsParentheses>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericArgs<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericArgs<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
GenericArgs {
args: ref __binding_0,
constraints: ref __binding_1,
parenthesized: ref __binding_2,
span_ext: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
621pub struct GenericArgs<'hir> {
622 pub args: &'hir [GenericArg<'hir>],
624 pub constraints: &'hir [AssocItemConstraint<'hir>],
626 pub parenthesized: GenericArgsParentheses,
631 pub span_ext: Span,
644}
645
646impl<'hir> GenericArgs<'hir> {
647 pub const fn none() -> Self {
648 Self {
649 args: &[],
650 constraints: &[],
651 parenthesized: GenericArgsParentheses::No,
652 span_ext: DUMMY_SP,
653 }
654 }
655
656 pub fn paren_sugar_inputs_output(&self) -> Option<(&[Ty<'hir>], &Ty<'hir>)> {
661 if self.parenthesized != GenericArgsParentheses::ParenSugar {
662 return None;
663 }
664
665 let inputs = self
666 .args
667 .iter()
668 .find_map(|arg| {
669 let GenericArg::Type(ty) = arg else { return None };
670 let TyKind::Tup(tys) = &ty.kind else { return None };
671 Some(tys)
672 })
673 .unwrap();
674
675 Some((inputs, self.paren_sugar_output_inner()))
676 }
677
678 pub fn paren_sugar_output(&self) -> Option<&Ty<'hir>> {
683 (self.parenthesized == GenericArgsParentheses::ParenSugar)
684 .then(|| self.paren_sugar_output_inner())
685 }
686
687 fn paren_sugar_output_inner(&self) -> &Ty<'hir> {
688 let [constraint] = self.constraints.try_into().unwrap();
689 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);
690 constraint.ty().unwrap()
691 }
692
693 pub fn has_err(&self) -> Option<ErrorGuaranteed> {
694 self.args
695 .iter()
696 .find_map(|arg| {
697 let GenericArg::Type(ty) = arg else { return None };
698 let TyKind::Err(guar) = ty.kind else { return None };
699 Some(guar)
700 })
701 .or_else(|| {
702 self.constraints.iter().find_map(|constraint| {
703 let TyKind::Err(guar) = constraint.ty()?.kind else { return None };
704 Some(guar)
705 })
706 })
707 }
708
709 #[inline]
710 pub fn num_lifetime_params(&self) -> usize {
711 self.args.iter().filter(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
712 }
713
714 #[inline]
715 pub fn has_lifetime_params(&self) -> bool {
716 self.args.iter().any(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_)))
717 }
718
719 #[inline]
720 pub fn num_generic_params(&self) -> usize {
723 self.args.iter().filter(|arg| !#[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
724 }
725
726 pub fn span(&self) -> Option<Span> {
732 let span_ext = self.span_ext()?;
733 Some(span_ext.with_lo(span_ext.lo() + BytePos(1)).with_hi(span_ext.hi() - BytePos(1)))
734 }
735
736 pub fn span_ext(&self) -> Option<Span> {
738 Some(self.span_ext).filter(|span| !span.is_empty())
739 }
740
741 pub fn is_empty(&self) -> bool {
742 self.args.is_empty()
743 }
744}
745
746#[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_receiver_is_total_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for GenericArgsParentheses {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
GenericArgsParentheses::No => "No",
GenericArgsParentheses::ReturnTypeNotation =>
"ReturnTypeNotation",
GenericArgsParentheses::ParenSugar => "ParenSugar",
})
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for GenericArgsParentheses where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericArgsParentheses::No => {}
GenericArgsParentheses::ReturnTypeNotation => {}
GenericArgsParentheses::ParenSugar => {}
}
}
}
};HashStable_Generic)]
747pub enum GenericArgsParentheses {
748 No,
749 ReturnTypeNotation,
752 ParenSugar,
754}
755
756#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<BoundConstness>;
let _: ::core::cmp::AssertParamIsEq<BoundPolarity>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for TraitBoundModifiers {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.constness, state);
::core::hash::Hash::hash(&self.polarity, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for TraitBoundModifiers {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"TraitBoundModifiers", "constness", &self.constness, "polarity",
&&self.polarity)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for TraitBoundModifiers where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitBoundModifiers {
constness: ref __binding_0, polarity: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
758pub struct TraitBoundModifiers {
759 pub constness: BoundConstness,
760 pub polarity: BoundPolarity,
761}
762
763impl TraitBoundModifiers {
764 pub const NONE: Self =
765 TraitBoundModifiers { constness: BoundConstness::Never, polarity: BoundPolarity::Positive };
766}
767
768#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericBound<'hir> {
#[inline]
fn clone(&self) -> GenericBound<'hir> {
let _: ::core::clone::AssertParamIsClone<PolyTraitRef<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
let _:
::core::clone::AssertParamIsClone<&'hir [PreciseCapturingArg<'hir>]>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericBound<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericBound<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
GenericBound::Trait(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Trait",
&__self_0),
GenericBound::Outlives(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Outlives", &__self_0),
GenericBound::Use(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Use",
__self_0, &__self_1),
}
}
}Debug, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericBound<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericBound::Trait(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericBound::Outlives(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericBound::Use(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
769pub enum GenericBound<'hir> {
770 Trait(PolyTraitRef<'hir>),
771 Outlives(&'hir Lifetime),
772 Use(&'hir [PreciseCapturingArg<'hir>], Span),
773}
774
775impl GenericBound<'_> {
776 pub fn trait_ref(&self) -> Option<&TraitRef<'_>> {
777 match self {
778 GenericBound::Trait(data) => Some(&data.trait_ref),
779 _ => None,
780 }
781 }
782
783 pub fn span(&self) -> Span {
784 match self {
785 GenericBound::Trait(t, ..) => t.span,
786 GenericBound::Outlives(l) => l.ident.span,
787 GenericBound::Use(_, span) => *span,
788 }
789 }
790}
791
792pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>];
793
794#[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_receiver_is_total_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for MissingLifetimeKind {
#[inline]
fn partial_cmp(&self, other: &MissingLifetimeKind)
-> ::core::option::Option<::core::cmp::Ordering> {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for MissingLifetimeKind {
#[inline]
fn cmp(&self, other: &MissingLifetimeKind) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for MissingLifetimeKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for MissingLifetimeKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
MissingLifetimeKind::Underscore => {}
MissingLifetimeKind::Ampersand => {}
MissingLifetimeKind::Comma => {}
MissingLifetimeKind::Brackets => {}
}
}
}
};HashStable_Generic, #[automatically_derived]
impl ::core::fmt::Debug for MissingLifetimeKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
MissingLifetimeKind::Underscore => "Underscore",
MissingLifetimeKind::Ampersand => "Ampersand",
MissingLifetimeKind::Comma => "Comma",
MissingLifetimeKind::Brackets => "Brackets",
})
}
}Debug)]
795pub enum MissingLifetimeKind {
796 Underscore,
798 Ampersand,
800 Comma,
802 Brackets,
804}
805
806#[derive(#[automatically_derived]
impl ::core::marker::Copy for LifetimeParamKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeParamKind {
#[inline]
fn clone(&self) -> LifetimeParamKind {
let _: ::core::clone::AssertParamIsClone<MissingLifetimeKind>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for LifetimeParamKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
LifetimeParamKind::Explicit =>
::core::fmt::Formatter::write_str(f, "Explicit"),
LifetimeParamKind::Elided(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Elided",
&__self_0),
LifetimeParamKind::Error =>
::core::fmt::Formatter::write_str(f, "Error"),
}
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LifetimeParamKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LifetimeParamKind::Explicit => {}
LifetimeParamKind::Elided(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
LifetimeParamKind::Error => {}
}
}
}
};HashStable_Generic)]
807pub enum LifetimeParamKind {
808 Explicit,
811
812 Elided(MissingLifetimeKind),
815
816 Error,
818}
819
820#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericParamKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
GenericParamKind::Lifetime { kind: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Lifetime", "kind", &__self_0),
GenericParamKind::Type { default: __self_0, synthetic: __self_1 }
=>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Type",
"default", __self_0, "synthetic", &__self_1),
GenericParamKind::Const { ty: __self_0, default: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Const",
"ty", __self_0, "default", &__self_1),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericParamKind<'hir> {
#[inline]
fn clone(&self) -> GenericParamKind<'hir> {
let _: ::core::clone::AssertParamIsClone<LifetimeParamKind>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _:
::core::clone::AssertParamIsClone<Option<&'hir ConstArg<'hir>>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericParamKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericParamKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericParamKind::Lifetime { kind: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericParamKind::Type {
default: ref __binding_0, synthetic: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
GenericParamKind::Const {
ty: ref __binding_0, default: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
821pub enum GenericParamKind<'hir> {
822 Lifetime {
824 kind: LifetimeParamKind,
825 },
826 Type {
827 default: Option<&'hir Ty<'hir>>,
828 synthetic: bool,
829 },
830 Const {
831 ty: &'hir Ty<'hir>,
832 default: Option<&'hir ConstArg<'hir>>,
834 },
835}
836
837#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericParam<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["hir_id", "def_id", "name", "span", "pure_wrt_drop", "kind",
"colon_span", "source"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.hir_id, &self.def_id, &self.name, &self.span,
&self.pure_wrt_drop, &self.kind, &self.colon_span,
&&self.source];
::core::fmt::Formatter::debug_struct_fields_finish(f, "GenericParam",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericParam<'hir> {
#[inline]
fn clone(&self) -> GenericParam<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<ParamName>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<GenericParamKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<Span>>;
let _: ::core::clone::AssertParamIsClone<GenericParamSource>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericParam<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericParam<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
GenericParam {
hir_id: ref __binding_0,
def_id: ref __binding_1,
name: ref __binding_2,
span: ref __binding_3,
pure_wrt_drop: ref __binding_4,
kind: ref __binding_5,
colon_span: ref __binding_6,
source: ref __binding_7 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
{ __binding_7.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
838pub struct GenericParam<'hir> {
839 #[stable_hasher(ignore)]
840 pub hir_id: HirId,
841 pub def_id: LocalDefId,
842 pub name: ParamName,
843 pub span: Span,
844 pub pure_wrt_drop: bool,
845 pub kind: GenericParamKind<'hir>,
846 pub colon_span: Option<Span>,
847 pub source: GenericParamSource,
848}
849
850impl<'hir> GenericParam<'hir> {
851 pub fn is_impl_trait(&self) -> bool {
855 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Type { synthetic: true, .. } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Type { synthetic: true, .. })
856 }
857
858 pub fn is_elided_lifetime(&self) -> bool {
862 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) })
863 }
864}
865
866#[derive(#[automatically_derived]
impl ::core::fmt::Debug for GenericParamSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
GenericParamSource::Generics => "Generics",
GenericParamSource::Binder => "Binder",
})
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for GenericParamSource {
#[inline]
fn clone(&self) -> GenericParamSource { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for GenericParamSource { }Copy, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for GenericParamSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericParamSource::Generics => {}
GenericParamSource::Binder => {}
}
}
}
};HashStable_Generic)]
873pub enum GenericParamSource {
874 Generics,
876 Binder,
878}
879
880#[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)]
881pub struct GenericParamCount {
882 pub lifetimes: usize,
883 pub types: usize,
884 pub consts: usize,
885 pub infer: usize,
886}
887
888#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Generics<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Generics",
"params", &self.params, "predicates", &self.predicates,
"has_where_clause_predicates", &self.has_where_clause_predicates,
"where_clause_span", &self.where_clause_span, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Generics<'hir> {
#[inline]
fn clone(&self) -> Generics<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _:
::core::clone::AssertParamIsClone<&'hir [WherePredicate<'hir>]>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Generics<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Generics<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Generics {
params: ref __binding_0,
predicates: ref __binding_1,
has_where_clause_predicates: ref __binding_2,
where_clause_span: ref __binding_3,
span: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
891pub struct Generics<'hir> {
892 pub params: &'hir [GenericParam<'hir>],
893 pub predicates: &'hir [WherePredicate<'hir>],
894 pub has_where_clause_predicates: bool,
895 pub where_clause_span: Span,
896 pub span: Span,
897}
898
899impl<'hir> Generics<'hir> {
900 pub const fn empty() -> &'hir Generics<'hir> {
901 const NOPE: Generics<'_> = Generics {
902 params: &[],
903 predicates: &[],
904 has_where_clause_predicates: false,
905 where_clause_span: DUMMY_SP,
906 span: DUMMY_SP,
907 };
908 &NOPE
909 }
910
911 pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'hir>> {
912 self.params.iter().find(|¶m| name == param.name.ident().name)
913 }
914
915 pub fn span_for_lifetime_suggestion(&self) -> Option<Span> {
917 if let Some(first) = self.params.first()
918 && self.span.contains(first.span)
919 {
920 Some(first.span.shrink_to_lo())
923 } else {
924 None
925 }
926 }
927
928 pub fn span_for_param_suggestion(&self) -> Option<Span> {
930 self.params.iter().any(|p| self.span.contains(p.span)).then(|| {
931 self.span.with_lo(self.span.hi() - BytePos(1)).shrink_to_lo()
934 })
935 }
936
937 pub fn tail_span_for_predicate_suggestion(&self) -> Span {
940 let end = self.where_clause_span.shrink_to_hi();
941 if self.has_where_clause_predicates {
942 self.predicates
943 .iter()
944 .rfind(|&p| p.kind.in_where_clause())
945 .map_or(end, |p| p.span)
946 .shrink_to_hi()
947 .to(end)
948 } else {
949 end
950 }
951 }
952
953 pub fn add_where_or_trailing_comma(&self) -> &'static str {
954 if self.has_where_clause_predicates {
955 ","
956 } else if self.where_clause_span.is_empty() {
957 " where"
958 } else {
959 ""
961 }
962 }
963
964 pub fn bounds_for_param(
965 &self,
966 param_def_id: LocalDefId,
967 ) -> impl Iterator<Item = &WhereBoundPredicate<'hir>> {
968 self.predicates.iter().filter_map(move |pred| match pred.kind {
969 WherePredicateKind::BoundPredicate(bp)
970 if bp.is_param_bound(param_def_id.to_def_id()) =>
971 {
972 Some(bp)
973 }
974 _ => None,
975 })
976 }
977
978 pub fn outlives_for_param(
979 &self,
980 param_def_id: LocalDefId,
981 ) -> impl Iterator<Item = &WhereRegionPredicate<'_>> {
982 self.predicates.iter().filter_map(move |pred| match pred.kind {
983 WherePredicateKind::RegionPredicate(rp) if rp.is_param_bound(param_def_id) => Some(rp),
984 _ => None,
985 })
986 }
987
988 pub fn bounds_span_for_suggestions(
999 &self,
1000 param_def_id: LocalDefId,
1001 ) -> Option<(Span, Option<Span>)> {
1002 self.bounds_for_param(param_def_id).flat_map(|bp| bp.bounds.iter().rev()).find_map(
1003 |bound| {
1004 let span_for_parentheses = if let Some(trait_ref) = bound.trait_ref()
1005 && let [.., segment] = trait_ref.path.segments
1006 && let Some(ret_ty) = segment.args().paren_sugar_output()
1007 && let ret_ty = ret_ty.peel_refs()
1008 && let TyKind::TraitObject(_, tagged_ptr) = ret_ty.kind
1009 && let TraitObjectSyntax::Dyn = tagged_ptr.tag()
1010 && ret_ty.span.can_be_used_for_suggestions()
1011 {
1012 Some(ret_ty.span)
1013 } else {
1014 None
1015 };
1016
1017 span_for_parentheses.map_or_else(
1018 || {
1019 let bs = bound.span();
1022 bs.from_expansion().not().then(|| (bs.shrink_to_hi(), None))
1027 },
1028 |span| Some((span.shrink_to_hi(), Some(span.shrink_to_lo()))),
1029 )
1030 },
1031 )
1032 }
1033
1034 pub fn span_for_predicate_removal(&self, pos: usize) -> Span {
1035 let predicate = &self.predicates[pos];
1036 let span = predicate.span;
1037
1038 if !predicate.kind.in_where_clause() {
1039 return span;
1042 }
1043
1044 if pos < self.predicates.len() - 1 {
1046 let next_pred = &self.predicates[pos + 1];
1047 if next_pred.kind.in_where_clause() {
1048 return span.until(next_pred.span);
1051 }
1052 }
1053
1054 if pos > 0 {
1055 let prev_pred = &self.predicates[pos - 1];
1056 if prev_pred.kind.in_where_clause() {
1057 return prev_pred.span.shrink_to_hi().to(span);
1060 }
1061 }
1062
1063 self.where_clause_span
1067 }
1068
1069 pub fn span_for_bound_removal(&self, predicate_pos: usize, bound_pos: usize) -> Span {
1070 let predicate = &self.predicates[predicate_pos];
1071 let bounds = predicate.kind.bounds();
1072
1073 if bounds.len() == 1 {
1074 return self.span_for_predicate_removal(predicate_pos);
1075 }
1076
1077 let bound_span = bounds[bound_pos].span();
1078 if bound_pos < bounds.len() - 1 {
1079 bound_span.to(bounds[bound_pos + 1].span().shrink_to_lo())
1085 } else {
1086 bound_span.with_lo(bounds[bound_pos - 1].span().hi())
1092 }
1093 }
1094}
1095
1096#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WherePredicate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"WherePredicate", "hir_id", &self.hir_id, "span", &self.span,
"kind", &&self.kind)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WherePredicate<'hir> {
#[inline]
fn clone(&self) -> WherePredicate<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _:
::core::clone::AssertParamIsClone<&'hir WherePredicateKind<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WherePredicate<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
WherePredicate<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
WherePredicate {
hir_id: ref __binding_0,
span: ref __binding_1,
kind: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1098pub struct WherePredicate<'hir> {
1099 #[stable_hasher(ignore)]
1100 pub hir_id: HirId,
1101 pub span: Span,
1102 pub kind: &'hir WherePredicateKind<'hir>,
1103}
1104
1105#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WherePredicateKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
WherePredicateKind::BoundPredicate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"BoundPredicate", &__self_0),
WherePredicateKind::RegionPredicate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"RegionPredicate", &__self_0),
WherePredicateKind::EqPredicate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"EqPredicate", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WherePredicateKind<'hir> {
#[inline]
fn clone(&self) -> WherePredicateKind<'hir> {
let _: ::core::clone::AssertParamIsClone<WhereBoundPredicate<'hir>>;
let _: ::core::clone::AssertParamIsClone<WhereRegionPredicate<'hir>>;
let _: ::core::clone::AssertParamIsClone<WhereEqPredicate<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WherePredicateKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
WherePredicateKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
WherePredicateKind::BoundPredicate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
WherePredicateKind::RegionPredicate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
WherePredicateKind::EqPredicate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1107pub enum WherePredicateKind<'hir> {
1108 BoundPredicate(WhereBoundPredicate<'hir>),
1110 RegionPredicate(WhereRegionPredicate<'hir>),
1112 EqPredicate(WhereEqPredicate<'hir>),
1114}
1115
1116impl<'hir> WherePredicateKind<'hir> {
1117 pub fn in_where_clause(&self) -> bool {
1118 match self {
1119 WherePredicateKind::BoundPredicate(p) => p.origin == PredicateOrigin::WhereClause,
1120 WherePredicateKind::RegionPredicate(p) => p.in_where_clause,
1121 WherePredicateKind::EqPredicate(_) => false,
1122 }
1123 }
1124
1125 pub fn bounds(&self) -> GenericBounds<'hir> {
1126 match self {
1127 WherePredicateKind::BoundPredicate(p) => p.bounds,
1128 WherePredicateKind::RegionPredicate(p) => p.bounds,
1129 WherePredicateKind::EqPredicate(_) => &[],
1130 }
1131 }
1132}
1133
1134#[derive(#[automatically_derived]
impl ::core::marker::Copy for PredicateOrigin { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PredicateOrigin {
#[inline]
fn clone(&self) -> PredicateOrigin { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for PredicateOrigin {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
PredicateOrigin::WhereClause => "WhereClause",
PredicateOrigin::GenericParam => "GenericParam",
PredicateOrigin::ImplTrait => "ImplTrait",
})
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for PredicateOrigin where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
PredicateOrigin::WhereClause => {}
PredicateOrigin::GenericParam => {}
PredicateOrigin::ImplTrait => {}
}
}
}
};HashStable_Generic, #[automatically_derived]
impl ::core::cmp::PartialEq for PredicateOrigin {
#[inline]
fn eq(&self, other: &PredicateOrigin) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for PredicateOrigin {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {}
}Eq)]
1135pub enum PredicateOrigin {
1136 WhereClause,
1137 GenericParam,
1138 ImplTrait,
1139}
1140
1141#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WhereBoundPredicate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"WhereBoundPredicate", "origin", &self.origin,
"bound_generic_params", &self.bound_generic_params, "bounded_ty",
&self.bounded_ty, "bounds", &&self.bounds)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WhereBoundPredicate<'hir> {
#[inline]
fn clone(&self) -> WhereBoundPredicate<'hir> {
let _: ::core::clone::AssertParamIsClone<PredicateOrigin>;
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WhereBoundPredicate<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
WhereBoundPredicate<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
WhereBoundPredicate {
origin: ref __binding_0,
bound_generic_params: ref __binding_1,
bounded_ty: ref __binding_2,
bounds: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1143pub struct WhereBoundPredicate<'hir> {
1144 pub origin: PredicateOrigin,
1146 pub bound_generic_params: &'hir [GenericParam<'hir>],
1148 pub bounded_ty: &'hir Ty<'hir>,
1150 pub bounds: GenericBounds<'hir>,
1152}
1153
1154impl<'hir> WhereBoundPredicate<'hir> {
1155 pub fn is_param_bound(&self, param_def_id: DefId) -> bool {
1157 self.bounded_ty.as_generic_param().is_some_and(|(def_id, _)| def_id == param_def_id)
1158 }
1159}
1160
1161#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WhereRegionPredicate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"WhereRegionPredicate", "in_where_clause", &self.in_where_clause,
"lifetime", &self.lifetime, "bounds", &&self.bounds)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WhereRegionPredicate<'hir> {
#[inline]
fn clone(&self) -> WhereRegionPredicate<'hir> {
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WhereRegionPredicate<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
WhereRegionPredicate<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
WhereRegionPredicate {
in_where_clause: ref __binding_0,
lifetime: ref __binding_1,
bounds: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1163pub struct WhereRegionPredicate<'hir> {
1164 pub in_where_clause: bool,
1165 pub lifetime: &'hir Lifetime,
1166 pub bounds: GenericBounds<'hir>,
1167}
1168
1169impl<'hir> WhereRegionPredicate<'hir> {
1170 fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
1172 self.lifetime.kind == LifetimeKind::Param(param_def_id)
1173 }
1174}
1175
1176#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WhereEqPredicate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"WhereEqPredicate", "lhs_ty", &self.lhs_ty, "rhs_ty",
&&self.rhs_ty)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WhereEqPredicate<'hir> {
#[inline]
fn clone(&self) -> WhereEqPredicate<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WhereEqPredicate<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
WhereEqPredicate<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
WhereEqPredicate {
lhs_ty: ref __binding_0, rhs_ty: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1178pub struct WhereEqPredicate<'hir> {
1179 pub lhs_ty: &'hir Ty<'hir>,
1180 pub rhs_ty: &'hir Ty<'hir>,
1181}
1182
1183#[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)]
1187pub struct ParentedNode<'tcx> {
1188 pub parent: ItemLocalId,
1189 pub node: Node<'tcx>,
1190}
1191
1192#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttrArgs {
#[inline]
fn clone(&self) -> AttrArgs {
match self {
AttrArgs::Empty => AttrArgs::Empty,
AttrArgs::Delimited(__self_0) =>
AttrArgs::Delimited(::core::clone::Clone::clone(__self_0)),
AttrArgs::Eq { eq_span: __self_0, expr: __self_1 } =>
AttrArgs::Eq {
eq_span: ::core::clone::Clone::clone(__self_0),
expr: ::core::clone::Clone::clone(__self_1),
},
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AttrArgs {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
AttrArgs::Empty => ::core::fmt::Formatter::write_str(f, "Empty"),
AttrArgs::Delimited(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Delimited", &__self_0),
AttrArgs::Eq { eq_span: __self_0, expr: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Eq",
"eq_span", __self_0, "expr", &__self_1),
}
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AttrArgs where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
AttrArgs::Empty => {}
AttrArgs::Delimited(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
AttrArgs::Eq {
eq_span: ref __binding_0, expr: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for AttrArgs {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
AttrArgs::Empty => { 0usize }
AttrArgs::Delimited(ref __binding_0) => { 1usize }
AttrArgs::Eq {
eq_span: ref __binding_0, expr: ref __binding_1 } => {
2usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
AttrArgs::Empty => {}
AttrArgs::Delimited(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AttrArgs::Eq {
eq_span: ref __binding_0, expr: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for AttrArgs {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { AttrArgs::Empty }
1usize => {
AttrArgs::Delimited(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => {
AttrArgs::Eq {
eq_span: ::rustc_serialize::Decodable::decode(__decoder),
expr: ::rustc_serialize::Decodable::decode(__decoder),
}
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `AttrArgs`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
1194pub enum AttrArgs {
1195 Empty,
1197 Delimited(DelimArgs),
1199 Eq {
1201 eq_span: Span,
1203 expr: MetaItemLit,
1205 },
1206}
1207
1208#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttrPath {
#[inline]
fn clone(&self) -> AttrPath {
AttrPath {
segments: ::core::clone::Clone::clone(&self.segments),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AttrPath {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "AttrPath",
"segments", &self.segments, "span", &&self.span)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AttrPath where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
AttrPath { segments: ref __binding_0, span: ref __binding_1
} => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for AttrPath {
fn encode(&self, __encoder: &mut __E) {
match *self {
AttrPath { segments: ref __binding_0, span: ref __binding_1
} => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for AttrPath {
fn decode(__decoder: &mut __D) -> Self {
AttrPath {
segments: ::rustc_serialize::Decodable::decode(__decoder),
span: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable)]
1209pub struct AttrPath {
1210 pub segments: Box<[Symbol]>,
1211 pub span: Span,
1212}
1213
1214impl IntoDiagArg for AttrPath {
1215 fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>) -> DiagArgValue {
1216 self.to_string().into_diag_arg(path)
1217 }
1218}
1219
1220impl AttrPath {
1221 pub fn from_ast(path: &ast::Path, lower_span: impl Copy + Fn(Span) -> Span) -> Self {
1222 AttrPath {
1223 segments: path
1224 .segments
1225 .iter()
1226 .map(|i| i.ident.name)
1227 .collect::<Vec<_>>()
1228 .into_boxed_slice(),
1229 span: lower_span(path.span),
1230 }
1231 }
1232}
1233
1234impl fmt::Display for AttrPath {
1235 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1236 f.write_fmt(format_args!("{0}",
join_path_idents(self.segments.iter().map(|i|
Ident { name: *i, span: DUMMY_SP }))))write!(
1237 f,
1238 "{}",
1239 join_path_idents(self.segments.iter().map(|i| Ident { name: *i, span: DUMMY_SP }))
1240 )
1241 }
1242}
1243
1244#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttrItem {
#[inline]
fn clone(&self) -> AttrItem {
AttrItem {
path: ::core::clone::Clone::clone(&self.path),
args: ::core::clone::Clone::clone(&self.args),
id: ::core::clone::Clone::clone(&self.id),
style: ::core::clone::Clone::clone(&self.style),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AttrItem {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "AttrItem",
"path", &self.path, "args", &self.args, "id", &self.id, "style",
&self.style, "span", &&self.span)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AttrItem where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
AttrItem {
path: ref __binding_0,
args: ref __binding_1,
id: ref __binding_2,
style: ref __binding_3,
span: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for AttrItem {
fn encode(&self, __encoder: &mut __E) {
match *self {
AttrItem {
path: ref __binding_0,
args: ref __binding_1,
id: ref __binding_2,
style: ref __binding_3,
span: ref __binding_4 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_4,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for AttrItem {
fn decode(__decoder: &mut __D) -> Self {
AttrItem {
path: ::rustc_serialize::Decodable::decode(__decoder),
args: ::rustc_serialize::Decodable::decode(__decoder),
id: ::rustc_serialize::Decodable::decode(__decoder),
style: ::rustc_serialize::Decodable::decode(__decoder),
span: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable)]
1245pub struct AttrItem {
1246 pub path: AttrPath,
1248 pub args: AttrArgs,
1249 pub id: HashIgnoredAttrId,
1250 pub style: AttrStyle,
1253 pub span: Span,
1255}
1256
1257#[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)]
1260pub struct HashIgnoredAttrId {
1261 pub attr_id: AttrId,
1262}
1263
1264#[derive(#[automatically_derived]
impl ::core::clone::Clone for Attribute {
#[inline]
fn clone(&self) -> Attribute {
match self {
Attribute::Parsed(__self_0) =>
Attribute::Parsed(::core::clone::Clone::clone(__self_0)),
Attribute::Unparsed(__self_0) =>
Attribute::Unparsed(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Attribute {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Attribute::Parsed(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Parsed",
&__self_0),
Attribute::Unparsed(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Unparsed", &__self_0),
}
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Attribute {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Attribute::Parsed(ref __binding_0) => { 0usize }
Attribute::Unparsed(ref __binding_0) => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Attribute::Parsed(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
Attribute::Unparsed(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Attribute {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
Attribute::Parsed(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
Attribute::Unparsed(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Attribute`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Attribute where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Attribute::Parsed(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Attribute::Unparsed(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1265pub enum Attribute {
1266 Parsed(AttributeKind),
1272
1273 Unparsed(Box<AttrItem>),
1276}
1277
1278impl Attribute {
1279 pub fn get_normal_item(&self) -> &AttrItem {
1280 match &self {
1281 Attribute::Unparsed(normal) => &normal,
1282 _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1283 }
1284 }
1285
1286 pub fn unwrap_normal_item(self) -> AttrItem {
1287 match self {
1288 Attribute::Unparsed(normal) => *normal,
1289 _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1290 }
1291 }
1292
1293 pub fn value_lit(&self) -> Option<&MetaItemLit> {
1294 match &self {
1295 Attribute::Unparsed(n) => match n.as_ref() {
1296 AttrItem { args: AttrArgs::Eq { eq_span: _, expr }, .. } => Some(expr),
1297 _ => None,
1298 },
1299 _ => None,
1300 }
1301 }
1302
1303 pub fn is_parsed_attr(&self) -> bool {
1304 match self {
1305 Attribute::Parsed(_) => true,
1306 Attribute::Unparsed(_) => false,
1307 }
1308 }
1309}
1310
1311impl AttributeExt for Attribute {
1312 #[inline]
1313 fn id(&self) -> AttrId {
1314 match &self {
1315 Attribute::Unparsed(u) => u.id.attr_id,
1316 _ => ::core::panicking::panic("explicit panic")panic!(),
1317 }
1318 }
1319
1320 #[inline]
1321 fn meta_item_list(&self) -> Option<ThinVec<ast::MetaItemInner>> {
1322 match &self {
1323 Attribute::Unparsed(n) => match n.as_ref() {
1324 AttrItem { args: AttrArgs::Delimited(d), .. } => {
1325 ast::MetaItemKind::list_from_tokens(d.tokens.clone())
1326 }
1327 _ => None,
1328 },
1329 _ => None,
1330 }
1331 }
1332
1333 #[inline]
1334 fn value_str(&self) -> Option<Symbol> {
1335 self.value_lit().and_then(|x| x.value_str())
1336 }
1337
1338 #[inline]
1339 fn value_span(&self) -> Option<Span> {
1340 self.value_lit().map(|i| i.span)
1341 }
1342
1343 #[inline]
1345 fn name(&self) -> Option<Symbol> {
1346 match &self {
1347 Attribute::Unparsed(n) => {
1348 if let [ident] = n.path.segments.as_ref() {
1349 Some(*ident)
1350 } else {
1351 None
1352 }
1353 }
1354 _ => None,
1355 }
1356 }
1357
1358 #[inline]
1359 fn path_matches(&self, name: &[Symbol]) -> bool {
1360 match &self {
1361 Attribute::Unparsed(n) => n.path.segments.iter().eq(name),
1362 _ => false,
1363 }
1364 }
1365
1366 #[inline]
1367 fn is_doc_comment(&self) -> Option<Span> {
1368 if let Attribute::Parsed(AttributeKind::DocComment { span, .. }) = self {
1369 Some(*span)
1370 } else {
1371 None
1372 }
1373 }
1374
1375 #[inline]
1376 fn span(&self) -> Span {
1377 match &self {
1378 Attribute::Unparsed(u) => u.span,
1379 Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
1381 Attribute::Parsed(AttributeKind::Deprecation { span, .. }) => *span,
1382 Attribute::Parsed(AttributeKind::CfgTrace(cfgs)) => cfgs[0].1,
1383 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:?}"),
1384 }
1385 }
1386
1387 #[inline]
1388 fn is_word(&self) -> bool {
1389 match &self {
1390 Attribute::Unparsed(n) => {
1391 #[allow(non_exhaustive_omitted_patterns)] match n.args {
AttrArgs::Empty => true,
_ => false,
}matches!(n.args, AttrArgs::Empty)
1392 }
1393 _ => false,
1394 }
1395 }
1396
1397 #[inline]
1398 fn symbol_path(&self) -> Option<SmallVec<[Symbol; 1]>> {
1399 match &self {
1400 Attribute::Unparsed(n) => Some(n.path.segments.iter().copied().collect()),
1401 _ => None,
1402 }
1403 }
1404
1405 fn path_span(&self) -> Option<Span> {
1406 match &self {
1407 Attribute::Unparsed(attr) => Some(attr.path.span),
1408 Attribute::Parsed(_) => None,
1409 }
1410 }
1411
1412 #[inline]
1413 fn doc_str(&self) -> Option<Symbol> {
1414 match &self {
1415 Attribute::Parsed(AttributeKind::DocComment { comment, .. }) => Some(*comment),
1416 _ => None,
1417 }
1418 }
1419
1420 #[inline]
1421 fn deprecation_note(&self) -> Option<Ident> {
1422 match &self {
1423 Attribute::Parsed(AttributeKind::Deprecation { deprecation, .. }) => deprecation.note,
1424 _ => None,
1425 }
1426 }
1427
1428 fn is_automatically_derived_attr(&self) -> bool {
1429 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)) => true,
_ => false,
}matches!(self, Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)))
1430 }
1431
1432 #[inline]
1433 fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1434 match &self {
1435 Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => {
1436 Some((*comment, *kind))
1437 }
1438 _ => None,
1439 }
1440 }
1441
1442 fn doc_resolution_scope(&self) -> Option<AttrStyle> {
1443 match self {
1444 Attribute::Parsed(AttributeKind::DocComment { style, .. }) => Some(*style),
1445 Attribute::Unparsed(attr) if self.has_name(sym::doc) && self.value_str().is_some() => {
1446 Some(attr.style)
1447 }
1448 _ => None,
1449 }
1450 }
1451
1452 fn is_proc_macro_attr(&self) -> bool {
1453 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::ProcMacro(..) |
AttributeKind::ProcMacroAttribute(..) |
AttributeKind::ProcMacroDerive { .. }) => true,
_ => false,
}matches!(
1454 self,
1455 Attribute::Parsed(
1456 AttributeKind::ProcMacro(..)
1457 | AttributeKind::ProcMacroAttribute(..)
1458 | AttributeKind::ProcMacroDerive { .. }
1459 )
1460 )
1461 }
1462
1463 fn is_doc_hidden(&self) -> bool {
1464 #[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())
1465 }
1466
1467 fn is_doc_keyword_or_attribute(&self) -> bool {
1468 #[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())
1469 }
1470}
1471
1472impl Attribute {
1474 #[inline]
1475 pub fn id(&self) -> AttrId {
1476 AttributeExt::id(self)
1477 }
1478
1479 #[inline]
1480 pub fn name(&self) -> Option<Symbol> {
1481 AttributeExt::name(self)
1482 }
1483
1484 #[inline]
1485 pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
1486 AttributeExt::meta_item_list(self)
1487 }
1488
1489 #[inline]
1490 pub fn value_str(&self) -> Option<Symbol> {
1491 AttributeExt::value_str(self)
1492 }
1493
1494 #[inline]
1495 pub fn value_span(&self) -> Option<Span> {
1496 AttributeExt::value_span(self)
1497 }
1498
1499 #[inline]
1500 pub fn path_matches(&self, name: &[Symbol]) -> bool {
1501 AttributeExt::path_matches(self, name)
1502 }
1503
1504 #[inline]
1505 pub fn is_doc_comment(&self) -> Option<Span> {
1506 AttributeExt::is_doc_comment(self)
1507 }
1508
1509 #[inline]
1510 pub fn has_name(&self, name: Symbol) -> bool {
1511 AttributeExt::has_name(self, name)
1512 }
1513
1514 #[inline]
1515 pub fn has_any_name(&self, names: &[Symbol]) -> bool {
1516 AttributeExt::has_any_name(self, names)
1517 }
1518
1519 #[inline]
1520 pub fn span(&self) -> Span {
1521 AttributeExt::span(self)
1522 }
1523
1524 #[inline]
1525 pub fn is_word(&self) -> bool {
1526 AttributeExt::is_word(self)
1527 }
1528
1529 #[inline]
1530 pub fn path(&self) -> SmallVec<[Symbol; 1]> {
1531 AttributeExt::path(self)
1532 }
1533
1534 #[inline]
1535 pub fn doc_str(&self) -> Option<Symbol> {
1536 AttributeExt::doc_str(self)
1537 }
1538
1539 #[inline]
1540 pub fn is_proc_macro_attr(&self) -> bool {
1541 AttributeExt::is_proc_macro_attr(self)
1542 }
1543
1544 #[inline]
1545 pub fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1546 AttributeExt::doc_str_and_fragment_kind(self)
1547 }
1548}
1549
1550#[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)]
1552pub struct AttributeMap<'tcx> {
1553 pub map: SortedMap<ItemLocalId, &'tcx [Attribute]>,
1554 pub define_opaque: Option<&'tcx [(Span, LocalDefId)]>,
1556 pub opt_hash: Option<Fingerprint>,
1558}
1559
1560impl<'tcx> AttributeMap<'tcx> {
1561 pub const EMPTY: &'static AttributeMap<'static> = &AttributeMap {
1562 map: SortedMap::new(),
1563 opt_hash: Some(Fingerprint::ZERO),
1564 define_opaque: None,
1565 };
1566
1567 #[inline]
1568 pub fn get(&self, id: ItemLocalId) -> &'tcx [Attribute] {
1569 self.map.get(&id).copied().unwrap_or(&[])
1570 }
1571}
1572
1573pub struct OwnerNodes<'tcx> {
1577 pub opt_hash_including_bodies: Option<Fingerprint>,
1580 pub nodes: IndexVec<ItemLocalId, ParentedNode<'tcx>>,
1585 pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>,
1587}
1588
1589impl<'tcx> OwnerNodes<'tcx> {
1590 pub fn node(&self) -> OwnerNode<'tcx> {
1591 self.nodes[ItemLocalId::ZERO].node.as_owner().unwrap()
1593 }
1594}
1595
1596impl fmt::Debug for OwnerNodes<'_> {
1597 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1598 f.debug_struct("OwnerNodes")
1599 .field("node", &self.nodes[ItemLocalId::ZERO])
1601 .field(
1602 "parents",
1603 &fmt::from_fn(|f| {
1604 f.debug_list()
1605 .entries(self.nodes.iter_enumerated().map(|(id, parented_node)| {
1606 fmt::from_fn(move |f| f.write_fmt(format_args!("({1:?}, {0:?})", parented_node.parent, id))write!(f, "({id:?}, {:?})", parented_node.parent))
1607 }))
1608 .finish()
1609 }),
1610 )
1611 .field("bodies", &self.bodies)
1612 .field("opt_hash_including_bodies", &self.opt_hash_including_bodies)
1613 .finish()
1614 }
1615}
1616
1617#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for OwnerInfo<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "OwnerInfo",
"nodes", &self.nodes, "parenting", &self.parenting, "attrs",
&self.attrs, "trait_map", &self.trait_map, "delayed_lints",
&&self.delayed_lints)
}
}Debug, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
OwnerInfo<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
OwnerInfo {
nodes: ref __binding_0,
parenting: ref __binding_1,
attrs: ref __binding_2,
trait_map: ref __binding_3,
delayed_lints: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1619pub struct OwnerInfo<'hir> {
1620 pub nodes: OwnerNodes<'hir>,
1622 pub parenting: LocalDefIdMap<ItemLocalId>,
1624 pub attrs: AttributeMap<'hir>,
1626 pub trait_map: ItemLocalMap<Box<[TraitCandidate]>>,
1629
1630 pub delayed_lints: DelayedLints,
1633}
1634
1635impl<'tcx> OwnerInfo<'tcx> {
1636 #[inline]
1637 pub fn node(&self) -> OwnerNode<'tcx> {
1638 self.nodes.node()
1639 }
1640}
1641
1642#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for MaybeOwner<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for MaybeOwner<'tcx> {
#[inline]
fn clone(&self) -> MaybeOwner<'tcx> {
let _: ::core::clone::AssertParamIsClone<&'tcx OwnerInfo<'tcx>>;
let _: ::core::clone::AssertParamIsClone<HirId>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for MaybeOwner<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
MaybeOwner::Owner(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Owner",
&__self_0),
MaybeOwner::NonOwner(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"NonOwner", &__self_0),
MaybeOwner::Phantom =>
::core::fmt::Formatter::write_str(f, "Phantom"),
}
}
}Debug, const _: () =
{
impl<'tcx, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
MaybeOwner<'tcx> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
MaybeOwner::Owner(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
MaybeOwner::NonOwner(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
MaybeOwner::Phantom => {}
}
}
}
};HashStable_Generic)]
1643pub enum MaybeOwner<'tcx> {
1644 Owner(&'tcx OwnerInfo<'tcx>),
1645 NonOwner(HirId),
1646 Phantom,
1648}
1649
1650impl<'tcx> MaybeOwner<'tcx> {
1651 pub fn as_owner(self) -> Option<&'tcx OwnerInfo<'tcx>> {
1652 match self {
1653 MaybeOwner::Owner(i) => Some(i),
1654 MaybeOwner::NonOwner(_) | MaybeOwner::Phantom => None,
1655 }
1656 }
1657
1658 pub fn unwrap(self) -> &'tcx OwnerInfo<'tcx> {
1659 self.as_owner().unwrap_or_else(|| { ::core::panicking::panic_fmt(format_args!("Not a HIR owner")); }panic!("Not a HIR owner"))
1660 }
1661}
1662
1663#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Crate<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Crate",
"owners", &self.owners, "opt_hir_hash", &&self.opt_hir_hash)
}
}Debug)]
1670pub struct Crate<'hir> {
1671 pub owners: IndexVec<LocalDefId, MaybeOwner<'hir>>,
1672 pub opt_hir_hash: Option<Fingerprint>,
1674}
1675
1676#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Closure<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["def_id", "binder", "constness", "capture_clause",
"bound_generic_params", "fn_decl", "body", "fn_decl_span",
"fn_arg_span", "kind"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.def_id, &self.binder, &self.constness,
&self.capture_clause, &self.bound_generic_params,
&self.fn_decl, &self.body, &self.fn_decl_span,
&self.fn_arg_span, &&self.kind];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Closure",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Closure<'hir> {
#[inline]
fn clone(&self) -> Closure<'hir> {
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<ClosureBinder>;
let _: ::core::clone::AssertParamIsClone<Constness>;
let _: ::core::clone::AssertParamIsClone<CaptureBy>;
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir FnDecl<'hir>>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Option<Span>>;
let _: ::core::clone::AssertParamIsClone<ClosureKind>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Closure<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Closure<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Closure {
def_id: ref __binding_0,
binder: ref __binding_1,
constness: ref __binding_2,
capture_clause: ref __binding_3,
bound_generic_params: ref __binding_4,
fn_decl: ref __binding_5,
body: ref __binding_6,
fn_decl_span: ref __binding_7,
fn_arg_span: ref __binding_8,
kind: ref __binding_9 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
{ __binding_7.hash_stable(__hcx, __hasher); }
{ __binding_8.hash_stable(__hcx, __hasher); }
{ __binding_9.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1677pub struct Closure<'hir> {
1678 pub def_id: LocalDefId,
1679 pub binder: ClosureBinder,
1680 pub constness: Constness,
1681 pub capture_clause: CaptureBy,
1682 pub bound_generic_params: &'hir [GenericParam<'hir>],
1683 pub fn_decl: &'hir FnDecl<'hir>,
1684 pub body: BodyId,
1685 pub fn_decl_span: Span,
1687 pub fn_arg_span: Option<Span>,
1689 pub kind: ClosureKind,
1690}
1691
1692#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<CoroutineKind>;
let _: ::core::cmp::AssertParamIsEq<CoroutineDesugaring>;
}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for ClosureKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ClosureKind::Closure =>
::core::fmt::Formatter::write_str(f, "Closure"),
ClosureKind::Coroutine(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Coroutine", &__self_0),
ClosureKind::CoroutineClosure(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"CoroutineClosure", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for ClosureKind { }Copy, #[automatically_derived]
impl ::core::hash::Hash for ClosureKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
ClosureKind::Coroutine(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
ClosureKind::CoroutineClosure(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ClosureKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ClosureKind::Closure => {}
ClosureKind::Coroutine(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ClosureKind::CoroutineClosure(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ClosureKind {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
ClosureKind::Closure => { 0usize }
ClosureKind::Coroutine(ref __binding_0) => { 1usize }
ClosureKind::CoroutineClosure(ref __binding_0) => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
ClosureKind::Closure => {}
ClosureKind::Coroutine(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
ClosureKind::CoroutineClosure(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ClosureKind {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { ClosureKind::Closure }
1usize => {
ClosureKind::Coroutine(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => {
ClosureKind::CoroutineClosure(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ClosureKind`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
1693pub enum ClosureKind {
1694 Closure,
1696 Coroutine(CoroutineKind),
1701 CoroutineClosure(CoroutineDesugaring),
1706}
1707
1708#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Block<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["stmts", "expr", "hir_id", "rules", "span",
"targeted_by_break"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.stmts, &self.expr, &self.hir_id, &self.rules, &self.span,
&&self.targeted_by_break];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Block", names,
values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Block<'hir> {
#[inline]
fn clone(&self) -> Block<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [Stmt<'hir>]>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<BlockCheckMode>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Block<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Block<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Block {
stmts: ref __binding_0,
expr: ref __binding_1,
hir_id: ref __binding_2,
rules: ref __binding_3,
span: ref __binding_4,
targeted_by_break: ref __binding_5 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{}
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1712pub struct Block<'hir> {
1713 pub stmts: &'hir [Stmt<'hir>],
1715 pub expr: Option<&'hir Expr<'hir>>,
1718 #[stable_hasher(ignore)]
1719 pub hir_id: HirId,
1720 pub rules: BlockCheckMode,
1722 pub span: Span,
1724 pub targeted_by_break: bool,
1728}
1729
1730impl<'hir> Block<'hir> {
1731 pub fn innermost_block(&self) -> &Block<'hir> {
1732 let mut block = self;
1733 while let Some(Expr { kind: ExprKind::Block(inner_block, _), .. }) = block.expr {
1734 block = inner_block;
1735 }
1736 block
1737 }
1738}
1739
1740#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TyPat<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "TyPat",
"hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TyPat<'hir> {
#[inline]
fn clone(&self) -> TyPat<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<TyPatKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TyPat<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TyPat<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TyPat {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1741pub struct TyPat<'hir> {
1742 #[stable_hasher(ignore)]
1743 pub hir_id: HirId,
1744 pub kind: TyPatKind<'hir>,
1745 pub span: Span,
1746}
1747
1748#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Pat<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "Pat", "hir_id",
&self.hir_id, "kind", &self.kind, "span", &self.span,
"default_binding_modes", &&self.default_binding_modes)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Pat<'hir> {
#[inline]
fn clone(&self) -> Pat<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<PatKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Pat<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Pat<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Pat {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2,
default_binding_modes: ref __binding_3 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1749pub struct Pat<'hir> {
1750 #[stable_hasher(ignore)]
1751 pub hir_id: HirId,
1752 pub kind: PatKind<'hir>,
1753 pub span: Span,
1754 pub default_binding_modes: bool,
1757}
1758
1759impl<'hir> Pat<'hir> {
1760 fn walk_short_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) -> bool {
1761 if !it(self) {
1762 return false;
1763 }
1764
1765 use PatKind::*;
1766 match self.kind {
1767 Missing => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1768 Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => true,
1769 Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => {
1770 s.walk_short_(it)
1771 }
1772 Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
1773 TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().all(|p| p.walk_short_(it)),
1774 Slice(before, slice, after) => {
1775 before.iter().chain(slice).chain(after.iter()).all(|p| p.walk_short_(it))
1776 }
1777 }
1778 }
1779
1780 pub fn walk_short(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) -> bool {
1787 self.walk_short_(&mut it)
1788 }
1789
1790 fn walk_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) {
1791 if !it(self) {
1792 return;
1793 }
1794
1795 use PatKind::*;
1796 match self.kind {
1797 Missing | Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => {}
1798 Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_(it),
1799 Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
1800 TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
1801 Slice(before, slice, after) => {
1802 before.iter().chain(slice).chain(after.iter()).for_each(|p| p.walk_(it))
1803 }
1804 }
1805 }
1806
1807 pub fn walk(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) {
1811 self.walk_(&mut it)
1812 }
1813
1814 pub fn walk_always(&self, mut it: impl FnMut(&Pat<'_>)) {
1818 self.walk(|p| {
1819 it(p);
1820 true
1821 })
1822 }
1823
1824 pub fn is_never_pattern(&self) -> bool {
1826 let mut is_never_pattern = false;
1827 self.walk(|pat| match &pat.kind {
1828 PatKind::Never => {
1829 is_never_pattern = true;
1830 false
1831 }
1832 PatKind::Or(s) => {
1833 is_never_pattern = s.iter().all(|p| p.is_never_pattern());
1834 false
1835 }
1836 _ => true,
1837 });
1838 is_never_pattern
1839 }
1840
1841 pub fn is_guaranteed_to_constitute_read_for_never(&self) -> bool {
1850 match self.kind {
1851 PatKind::Wild => false,
1853
1854 PatKind::Guard(pat, _) => pat.is_guaranteed_to_constitute_read_for_never(),
1857
1858 PatKind::Or(subpats) => {
1867 subpats.iter().all(|pat| pat.is_guaranteed_to_constitute_read_for_never())
1868 }
1869
1870 PatKind::Never => true,
1872
1873 PatKind::Missing
1876 | PatKind::Binding(_, _, _, _)
1877 | PatKind::Struct(_, _, _)
1878 | PatKind::TupleStruct(_, _, _)
1879 | PatKind::Tuple(_, _)
1880 | PatKind::Box(_)
1881 | PatKind::Ref(_, _, _)
1882 | PatKind::Deref(_)
1883 | PatKind::Expr(_)
1884 | PatKind::Range(_, _, _)
1885 | PatKind::Slice(_, _, _)
1886 | PatKind::Err(_) => true,
1887 }
1888 }
1889}
1890
1891#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatField<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "PatField",
"hir_id", &self.hir_id, "ident", &self.ident, "pat", &self.pat,
"is_shorthand", &self.is_shorthand, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatField<'hir> {
#[inline]
fn clone(&self) -> PatField<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatField<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PatField<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
PatField {
hir_id: ref __binding_0,
ident: ref __binding_1,
pat: ref __binding_2,
is_shorthand: ref __binding_3,
span: ref __binding_4 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1897pub struct PatField<'hir> {
1898 #[stable_hasher(ignore)]
1899 pub hir_id: HirId,
1900 pub ident: Ident,
1902 pub pat: &'hir Pat<'hir>,
1904 pub is_shorthand: bool,
1905 pub span: Span,
1906}
1907
1908#[derive(#[automatically_derived]
impl ::core::marker::Copy for RangeEnd { }Copy, #[automatically_derived]
impl ::core::clone::Clone for RangeEnd {
#[inline]
fn clone(&self) -> RangeEnd { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for RangeEnd {
#[inline]
fn eq(&self, other: &RangeEnd) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for RangeEnd {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
RangeEnd::Included => "Included",
RangeEnd::Excluded => "Excluded",
})
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for RangeEnd where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
RangeEnd::Included => {}
RangeEnd::Excluded => {}
}
}
}
};HashStable_Generic, #[automatically_derived]
impl ::core::hash::Hash for RangeEnd {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::cmp::Eq for RangeEnd {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_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)]
1909pub enum RangeEnd {
1910 Included,
1911 Excluded,
1912}
1913
1914impl fmt::Display for RangeEnd {
1915 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1916 f.write_str(match self {
1917 RangeEnd::Included => "..=",
1918 RangeEnd::Excluded => "..",
1919 })
1920 }
1921}
1922
1923#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for DotDotPos {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}Hash, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for DotDotPos where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
DotDotPos(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1927pub struct DotDotPos(u32);
1928
1929impl DotDotPos {
1930 pub fn new(n: Option<usize>) -> Self {
1932 match n {
1933 Some(n) => {
1934 if !(n < u32::MAX as usize) {
::core::panicking::panic("assertion failed: n < u32::MAX as usize")
};assert!(n < u32::MAX as usize);
1935 Self(n as u32)
1936 }
1937 None => Self(u32::MAX),
1938 }
1939 }
1940
1941 pub fn as_opt_usize(&self) -> Option<usize> {
1942 if self.0 == u32::MAX { None } else { Some(self.0 as usize) }
1943 }
1944}
1945
1946impl fmt::Debug for DotDotPos {
1947 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1948 self.as_opt_usize().fmt(f)
1949 }
1950}
1951
1952#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatExpr<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "PatExpr",
"hir_id", &self.hir_id, "span", &self.span, "kind", &&self.kind)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatExpr<'hir> {
#[inline]
fn clone(&self) -> PatExpr<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<PatExprKind<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatExpr<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PatExpr<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
PatExpr {
hir_id: ref __binding_0,
span: ref __binding_1,
kind: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1953pub struct PatExpr<'hir> {
1954 #[stable_hasher(ignore)]
1955 pub hir_id: HirId,
1956 pub span: Span,
1957 pub kind: PatExprKind<'hir>,
1958}
1959
1960#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatExprKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
PatExprKind::Lit { lit: __self_0, negated: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Lit",
"lit", __self_0, "negated", &__self_1),
PatExprKind::Path(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatExprKind<'hir> {
#[inline]
fn clone(&self) -> PatExprKind<'hir> {
let _: ::core::clone::AssertParamIsClone<Lit>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatExprKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PatExprKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
PatExprKind::Lit {
lit: ref __binding_0, negated: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
PatExprKind::Path(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1961pub enum PatExprKind<'hir> {
1962 Lit {
1963 lit: Lit,
1964 negated: bool,
1965 },
1966 Path(QPath<'hir>),
1968}
1969
1970#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TyPatKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TyPatKind::Range(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Range",
__self_0, &__self_1),
TyPatKind::NotNull =>
::core::fmt::Formatter::write_str(f, "NotNull"),
TyPatKind::Or(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Or",
&__self_0),
TyPatKind::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TyPatKind<'hir> {
#[inline]
fn clone(&self) -> TyPatKind<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [TyPat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TyPatKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TyPatKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
TyPatKind::Range(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyPatKind::NotNull => {}
TyPatKind::Or(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyPatKind::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1971pub enum TyPatKind<'hir> {
1972 Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>),
1974
1975 NotNull,
1977
1978 Or(&'hir [TyPat<'hir>]),
1980
1981 Err(ErrorGuaranteed),
1983}
1984
1985#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
PatKind::Missing =>
::core::fmt::Formatter::write_str(f, "Missing"),
PatKind::Wild => ::core::fmt::Formatter::write_str(f, "Wild"),
PatKind::Binding(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f,
"Binding", __self_0, __self_1, __self_2, &__self_3),
PatKind::Struct(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Struct",
__self_0, __self_1, &__self_2),
PatKind::TupleStruct(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f,
"TupleStruct", __self_0, __self_1, &__self_2),
PatKind::Or(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Or",
&__self_0),
PatKind::Never => ::core::fmt::Formatter::write_str(f, "Never"),
PatKind::Tuple(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Tuple",
__self_0, &__self_1),
PatKind::Box(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Box",
&__self_0),
PatKind::Deref(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Deref",
&__self_0),
PatKind::Ref(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Ref",
__self_0, __self_1, &__self_2),
PatKind::Expr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Expr",
&__self_0),
PatKind::Guard(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Guard",
__self_0, &__self_1),
PatKind::Range(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Range",
__self_0, __self_1, &__self_2),
PatKind::Slice(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Slice",
__self_0, __self_1, &__self_2),
PatKind::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatKind<'hir> {
#[inline]
fn clone(&self) -> PatKind<'hir> {
let _: ::core::clone::AssertParamIsClone<BindingMode>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Pat<'hir>>>;
let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [PatField<'hir>]>;
let _: ::core::clone::AssertParamIsClone<Option<Span>>;
let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<DotDotPos>;
let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<Pinnedness>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
let _: ::core::clone::AssertParamIsClone<&'hir PatExpr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir PatExpr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir PatExpr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<RangeEnd>;
let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Pat<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PatKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
PatKind::Missing => {}
PatKind::Wild => {}
PatKind::Binding(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
PatKind::Struct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
PatKind::TupleStruct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
PatKind::Or(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PatKind::Never => {}
PatKind::Tuple(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
PatKind::Box(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PatKind::Deref(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PatKind::Ref(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
PatKind::Expr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PatKind::Guard(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
PatKind::Range(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
PatKind::Slice(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
PatKind::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
1986pub enum PatKind<'hir> {
1987 Missing,
1989
1990 Wild,
1992
1993 Binding(BindingMode, HirId, Ident, Option<&'hir Pat<'hir>>),
2004
2005 Struct(QPath<'hir>, &'hir [PatField<'hir>], Option<Span>),
2008
2009 TupleStruct(QPath<'hir>, &'hir [Pat<'hir>], DotDotPos),
2013
2014 Or(&'hir [Pat<'hir>]),
2017
2018 Never,
2020
2021 Tuple(&'hir [Pat<'hir>], DotDotPos),
2025
2026 Box(&'hir Pat<'hir>),
2028
2029 Deref(&'hir Pat<'hir>),
2031
2032 Ref(&'hir Pat<'hir>, Pinnedness, Mutability),
2034
2035 Expr(&'hir PatExpr<'hir>),
2037
2038 Guard(&'hir Pat<'hir>, &'hir Expr<'hir>),
2040
2041 Range(Option<&'hir PatExpr<'hir>>, Option<&'hir PatExpr<'hir>>, RangeEnd),
2043
2044 Slice(&'hir [Pat<'hir>], Option<&'hir Pat<'hir>>, &'hir [Pat<'hir>]),
2054
2055 Err(ErrorGuaranteed),
2057}
2058
2059#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Stmt<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "Stmt",
"hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Stmt<'hir> {
#[inline]
fn clone(&self) -> Stmt<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<StmtKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Stmt<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Stmt<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Stmt {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2061pub struct Stmt<'hir> {
2062 #[stable_hasher(ignore)]
2063 pub hir_id: HirId,
2064 pub kind: StmtKind<'hir>,
2065 pub span: Span,
2066}
2067
2068#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for StmtKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
StmtKind::Let(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Let",
&__self_0),
StmtKind::Item(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Item",
&__self_0),
StmtKind::Expr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Expr",
&__self_0),
StmtKind::Semi(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Semi",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for StmtKind<'hir> {
#[inline]
fn clone(&self) -> StmtKind<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir LetStmt<'hir>>;
let _: ::core::clone::AssertParamIsClone<ItemId>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for StmtKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
StmtKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
StmtKind::Let(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
StmtKind::Item(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
StmtKind::Expr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
StmtKind::Semi(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2070pub enum StmtKind<'hir> {
2071 Let(&'hir LetStmt<'hir>),
2073
2074 Item(ItemId),
2076
2077 Expr(&'hir Expr<'hir>),
2079
2080 Semi(&'hir Expr<'hir>),
2082}
2083
2084#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for LetStmt<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["super_", "pat", "ty", "init", "els", "hir_id", "span",
"source"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.super_, &self.pat, &self.ty, &self.init, &self.els,
&self.hir_id, &self.span, &&self.source];
::core::fmt::Formatter::debug_struct_fields_finish(f, "LetStmt",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for LetStmt<'hir> {
#[inline]
fn clone(&self) -> LetStmt<'hir> {
let _: ::core::clone::AssertParamIsClone<Option<Span>>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Block<'hir>>>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<LocalSource>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for LetStmt<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
LetStmt<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
LetStmt {
super_: ref __binding_0,
pat: ref __binding_1,
ty: ref __binding_2,
init: ref __binding_3,
els: ref __binding_4,
hir_id: ref __binding_5,
span: ref __binding_6,
source: ref __binding_7 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{}
{ __binding_6.hash_stable(__hcx, __hasher); }
{ __binding_7.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2086pub struct LetStmt<'hir> {
2087 pub super_: Option<Span>,
2089 pub pat: &'hir Pat<'hir>,
2090 pub ty: Option<&'hir Ty<'hir>>,
2092 pub init: Option<&'hir Expr<'hir>>,
2094 pub els: Option<&'hir Block<'hir>>,
2096 #[stable_hasher(ignore)]
2097 pub hir_id: HirId,
2098 pub span: Span,
2099 pub source: LocalSource,
2103}
2104
2105#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Arm<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Arm", "hir_id",
&self.hir_id, "span", &self.span, "pat", &self.pat, "guard",
&self.guard, "body", &&self.body)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Arm<'hir> {
#[inline]
fn clone(&self) -> Arm<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Arm<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Arm<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Arm {
hir_id: ref __binding_0,
span: ref __binding_1,
pat: ref __binding_2,
guard: ref __binding_3,
body: ref __binding_4 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2108pub struct Arm<'hir> {
2109 #[stable_hasher(ignore)]
2110 pub hir_id: HirId,
2111 pub span: Span,
2112 pub pat: &'hir Pat<'hir>,
2114 pub guard: Option<&'hir Expr<'hir>>,
2116 pub body: &'hir Expr<'hir>,
2118}
2119
2120#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for LetExpr<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "LetExpr",
"span", &self.span, "pat", &self.pat, "ty", &self.ty, "init",
&self.init, "recovered", &&self.recovered)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for LetExpr<'hir> {
#[inline]
fn clone(&self) -> LetExpr<'hir> {
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<ast::Recovered>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for LetExpr<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
LetExpr<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
LetExpr {
span: ref __binding_0,
pat: ref __binding_1,
ty: ref __binding_2,
init: ref __binding_3,
recovered: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2126pub struct LetExpr<'hir> {
2127 pub span: Span,
2128 pub pat: &'hir Pat<'hir>,
2129 pub ty: Option<&'hir Ty<'hir>>,
2130 pub init: &'hir Expr<'hir>,
2131 pub recovered: ast::Recovered,
2134}
2135
2136#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ExprField<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "ExprField",
"hir_id", &self.hir_id, "ident", &self.ident, "expr", &self.expr,
"span", &self.span, "is_shorthand", &&self.is_shorthand)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ExprField<'hir> {
#[inline]
fn clone(&self) -> ExprField<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ExprField<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ExprField<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ExprField {
hir_id: ref __binding_0,
ident: ref __binding_1,
expr: ref __binding_2,
span: ref __binding_3,
is_shorthand: ref __binding_4 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2137pub struct ExprField<'hir> {
2138 #[stable_hasher(ignore)]
2139 pub hir_id: HirId,
2140 pub ident: Ident,
2141 pub expr: &'hir Expr<'hir>,
2142 pub span: Span,
2143 pub is_shorthand: bool,
2144}
2145
2146#[derive(#[automatically_derived]
impl ::core::marker::Copy for BlockCheckMode { }Copy, #[automatically_derived]
impl ::core::clone::Clone for BlockCheckMode {
#[inline]
fn clone(&self) -> BlockCheckMode {
let _: ::core::clone::AssertParamIsClone<UnsafeSource>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for BlockCheckMode {
#[inline]
fn eq(&self, other: &BlockCheckMode) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(BlockCheckMode::UnsafeBlock(__self_0),
BlockCheckMode::UnsafeBlock(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for BlockCheckMode {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
BlockCheckMode::DefaultBlock =>
::core::fmt::Formatter::write_str(f, "DefaultBlock"),
BlockCheckMode::UnsafeBlock(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"UnsafeBlock", &__self_0),
}
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for BlockCheckMode where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
BlockCheckMode::DefaultBlock => {}
BlockCheckMode::UnsafeBlock(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2147pub enum BlockCheckMode {
2148 DefaultBlock,
2149 UnsafeBlock(UnsafeSource),
2150}
2151
2152#[derive(#[automatically_derived]
impl ::core::marker::Copy for UnsafeSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for UnsafeSource {
#[inline]
fn clone(&self) -> UnsafeSource { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for UnsafeSource {
#[inline]
fn eq(&self, other: &UnsafeSource) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for UnsafeSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
UnsafeSource::CompilerGenerated => "CompilerGenerated",
UnsafeSource::UserProvided => "UserProvided",
})
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for UnsafeSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
UnsafeSource::CompilerGenerated => {}
UnsafeSource::UserProvided => {}
}
}
}
};HashStable_Generic)]
2153pub enum UnsafeSource {
2154 CompilerGenerated,
2155 UserProvided,
2156}
2157
2158#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<HirId>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for BodyId {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.hir_id, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for BodyId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "BodyId",
"hir_id", &&self.hir_id)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for BodyId where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
BodyId { hir_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2159pub struct BodyId {
2160 pub hir_id: HirId,
2161}
2162
2163#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Body<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Body",
"params", &self.params, "value", &&self.value)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Body<'hir> {
#[inline]
fn clone(&self) -> Body<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [Param<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Body<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Body<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Body { params: ref __binding_0, value: ref __binding_1 } =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2185pub struct Body<'hir> {
2186 pub params: &'hir [Param<'hir>],
2187 pub value: &'hir Expr<'hir>,
2188}
2189
2190impl<'hir> Body<'hir> {
2191 pub fn id(&self) -> BodyId {
2192 BodyId { hir_id: self.value.hir_id }
2193 }
2194}
2195
2196#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<CoroutineDesugaring>;
let _: ::core::cmp::AssertParamIsEq<CoroutineSource>;
let _: ::core::cmp::AssertParamIsEq<Movability>;
}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for CoroutineKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
CoroutineKind::Desugared(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"Desugared", __self_0, &__self_1),
CoroutineKind::Coroutine(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Coroutine", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CoroutineKind { }Copy, #[automatically_derived]
impl ::core::hash::Hash for CoroutineKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
CoroutineKind::Desugared(__self_0, __self_1) => {
::core::hash::Hash::hash(__self_0, state);
::core::hash::Hash::hash(__self_1, state)
}
CoroutineKind::Coroutine(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
}
}
}Hash, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for CoroutineKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
CoroutineKind::Desugared(ref __binding_0, ref __binding_1)
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
CoroutineKind::Coroutine(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for CoroutineKind {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
CoroutineKind::Desugared(ref __binding_0, ref __binding_1)
=> {
0usize
}
CoroutineKind::Coroutine(ref __binding_0) => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
CoroutineKind::Desugared(ref __binding_0, ref __binding_1)
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
CoroutineKind::Coroutine(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for CoroutineKind {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
CoroutineKind::Desugared(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
CoroutineKind::Coroutine(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CoroutineKind`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
2198pub enum CoroutineKind {
2199 Desugared(CoroutineDesugaring, CoroutineSource),
2201
2202 Coroutine(Movability),
2204}
2205
2206impl CoroutineKind {
2207 pub fn movability(self) -> Movability {
2208 match self {
2209 CoroutineKind::Desugared(CoroutineDesugaring::Async, _)
2210 | CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _) => Movability::Static,
2211 CoroutineKind::Desugared(CoroutineDesugaring::Gen, _) => Movability::Movable,
2212 CoroutineKind::Coroutine(mov) => mov,
2213 }
2214 }
2215
2216 pub fn is_fn_like(self) -> bool {
2217 #[allow(non_exhaustive_omitted_patterns)] match self {
CoroutineKind::Desugared(_, CoroutineSource::Fn) => true,
_ => false,
}matches!(self, CoroutineKind::Desugared(_, CoroutineSource::Fn))
2218 }
2219
2220 pub fn to_plural_string(&self) -> String {
2221 match self {
2222 CoroutineKind::Desugared(d, CoroutineSource::Fn) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}fn bodies", d))
})format!("{d:#}fn bodies"),
2223 CoroutineKind::Desugared(d, CoroutineSource::Block) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}blocks", d))
})format!("{d:#}blocks"),
2224 CoroutineKind::Desugared(d, CoroutineSource::Closure) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}closure bodies", d))
})format!("{d:#}closure bodies"),
2225 CoroutineKind::Coroutine(_) => "coroutines".to_string(),
2226 }
2227 }
2228}
2229
2230impl fmt::Display for CoroutineKind {
2231 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2232 match self {
2233 CoroutineKind::Desugared(d, k) => {
2234 d.fmt(f)?;
2235 k.fmt(f)
2236 }
2237 CoroutineKind::Coroutine(_) => f.write_str("coroutine"),
2238 }
2239 }
2240}
2241
2242#[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_receiver_is_total_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for CoroutineSource {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for CoroutineSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
CoroutineSource::Block => "Block",
CoroutineSource::Closure => "Closure",
CoroutineSource::Fn => "Fn",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CoroutineSource { }Copy, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for CoroutineSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
CoroutineSource::Block => {}
CoroutineSource::Closure => {}
CoroutineSource::Fn => {}
}
}
}
};HashStable_Generic, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for CoroutineSource {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
CoroutineSource::Block => { 0usize }
CoroutineSource::Closure => { 1usize }
CoroutineSource::Fn => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
CoroutineSource::Block => {}
CoroutineSource::Closure => {}
CoroutineSource::Fn => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for CoroutineSource {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { CoroutineSource::Block }
1usize => { CoroutineSource::Closure }
2usize => { CoroutineSource::Fn }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CoroutineSource`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
2248pub enum CoroutineSource {
2249 Block,
2251
2252 Closure,
2254
2255 Fn,
2257}
2258
2259impl fmt::Display for CoroutineSource {
2260 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2261 match self {
2262 CoroutineSource::Block => "block",
2263 CoroutineSource::Closure => "closure body",
2264 CoroutineSource::Fn => "fn body",
2265 }
2266 .fmt(f)
2267 }
2268}
2269
2270#[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_receiver_is_total_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for CoroutineDesugaring {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
CoroutineDesugaring::Async => "Async",
CoroutineDesugaring::Gen => "Gen",
CoroutineDesugaring::AsyncGen => "AsyncGen",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CoroutineDesugaring { }Copy, #[automatically_derived]
impl ::core::hash::Hash for CoroutineDesugaring {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for CoroutineDesugaring where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
CoroutineDesugaring::Async => {}
CoroutineDesugaring::Gen => {}
CoroutineDesugaring::AsyncGen => {}
}
}
}
};HashStable_Generic, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for CoroutineDesugaring {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
CoroutineDesugaring::Async => { 0usize }
CoroutineDesugaring::Gen => { 1usize }
CoroutineDesugaring::AsyncGen => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
CoroutineDesugaring::Async => {}
CoroutineDesugaring::Gen => {}
CoroutineDesugaring::AsyncGen => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for CoroutineDesugaring {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { CoroutineDesugaring::Async }
1usize => { CoroutineDesugaring::Gen }
2usize => { CoroutineDesugaring::AsyncGen }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CoroutineDesugaring`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
2271pub enum CoroutineDesugaring {
2272 Async,
2274
2275 Gen,
2277
2278 AsyncGen,
2281}
2282
2283impl fmt::Display for CoroutineDesugaring {
2284 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2285 match self {
2286 CoroutineDesugaring::Async => {
2287 if f.alternate() {
2288 f.write_str("`async` ")?;
2289 } else {
2290 f.write_str("async ")?
2291 }
2292 }
2293 CoroutineDesugaring::Gen => {
2294 if f.alternate() {
2295 f.write_str("`gen` ")?;
2296 } else {
2297 f.write_str("gen ")?
2298 }
2299 }
2300 CoroutineDesugaring::AsyncGen => {
2301 if f.alternate() {
2302 f.write_str("`async gen` ")?;
2303 } else {
2304 f.write_str("async gen ")?
2305 }
2306 }
2307 }
2308
2309 Ok(())
2310 }
2311}
2312
2313#[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)]
2314pub enum BodyOwnerKind {
2315 Fn,
2317
2318 Closure,
2320
2321 Const { inline: bool },
2323
2324 Static(Mutability),
2326
2327 GlobalAsm,
2329}
2330
2331impl BodyOwnerKind {
2332 pub fn is_fn_or_closure(self) -> bool {
2333 match self {
2334 BodyOwnerKind::Fn | BodyOwnerKind::Closure => true,
2335 BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(_) | BodyOwnerKind::GlobalAsm => {
2336 false
2337 }
2338 }
2339 }
2340}
2341
2342#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Mutability>;
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq)]
2344pub enum ConstContext {
2345 ConstFn,
2347
2348 Static(Mutability),
2350
2351 Const { inline: bool },
2361}
2362
2363impl ConstContext {
2364 pub fn keyword_name(self) -> &'static str {
2368 match self {
2369 Self::Const { .. } => "const",
2370 Self::Static(Mutability::Not) => "static",
2371 Self::Static(Mutability::Mut) => "static mut",
2372 Self::ConstFn => "const fn",
2373 }
2374 }
2375}
2376
2377impl fmt::Display for ConstContext {
2380 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2381 match *self {
2382 Self::Const { .. } => f.write_fmt(format_args!("constant"))write!(f, "constant"),
2383 Self::Static(_) => f.write_fmt(format_args!("static"))write!(f, "static"),
2384 Self::ConstFn => f.write_fmt(format_args!("constant function"))write!(f, "constant function"),
2385 }
2386 }
2387}
2388
2389impl IntoDiagArg for ConstContext {
2390 fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
2391 DiagArgValue::Str(Cow::Borrowed(match self {
2392 ConstContext::ConstFn => "const_fn",
2393 ConstContext::Static(_) => "static",
2394 ConstContext::Const { .. } => "const",
2395 }))
2396 }
2397}
2398
2399pub type Lit = Spanned<LitKind>;
2401
2402#[derive(#[automatically_derived]
impl ::core::marker::Copy for AnonConst { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AnonConst {
#[inline]
fn clone(&self) -> AnonConst {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AnonConst {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "AnonConst",
"hir_id", &self.hir_id, "def_id", &self.def_id, "body",
&self.body, "span", &&self.span)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AnonConst where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
AnonConst {
hir_id: ref __binding_0,
def_id: ref __binding_1,
body: ref __binding_2,
span: ref __binding_3 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2411pub struct AnonConst {
2412 #[stable_hasher(ignore)]
2413 pub hir_id: HirId,
2414 pub def_id: LocalDefId,
2415 pub body: BodyId,
2416 pub span: Span,
2417}
2418
2419#[derive(#[automatically_derived]
impl ::core::marker::Copy for ConstBlock { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ConstBlock {
#[inline]
fn clone(&self) -> ConstBlock {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ConstBlock {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "ConstBlock",
"hir_id", &self.hir_id, "def_id", &self.def_id, "body",
&&self.body)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ConstBlock where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ConstBlock {
hir_id: ref __binding_0,
def_id: ref __binding_1,
body: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2421pub struct ConstBlock {
2422 #[stable_hasher(ignore)]
2423 pub hir_id: HirId,
2424 pub def_id: LocalDefId,
2425 pub body: BodyId,
2426}
2427
2428#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Expr<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "Expr",
"hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Expr<'hir> {
#[inline]
fn clone(&self) -> Expr<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<ExprKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Expr<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Expr<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Expr {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2437pub struct Expr<'hir> {
2438 #[stable_hasher(ignore)]
2439 pub hir_id: HirId,
2440 pub kind: ExprKind<'hir>,
2441 pub span: Span,
2442}
2443
2444impl Expr<'_> {
2445 pub fn precedence(&self, has_attr: &dyn Fn(HirId) -> bool) -> ExprPrecedence {
2446 let prefix_attrs_precedence = || -> ExprPrecedence {
2447 if has_attr(self.hir_id) { ExprPrecedence::Prefix } else { ExprPrecedence::Unambiguous }
2448 };
2449
2450 match &self.kind {
2451 ExprKind::Closure(closure) => {
2452 match closure.fn_decl.output {
2453 FnRetTy::DefaultReturn(_) => ExprPrecedence::Jump,
2454 FnRetTy::Return(_) => prefix_attrs_precedence(),
2455 }
2456 }
2457
2458 ExprKind::Break(..)
2459 | ExprKind::Ret(..)
2460 | ExprKind::Yield(..)
2461 | ExprKind::Become(..) => ExprPrecedence::Jump,
2462
2463 ExprKind::Binary(op, ..) => op.node.precedence(),
2465 ExprKind::Cast(..) => ExprPrecedence::Cast,
2466
2467 ExprKind::Assign(..) |
2468 ExprKind::AssignOp(..) => ExprPrecedence::Assign,
2469
2470 ExprKind::AddrOf(..)
2472 | ExprKind::Let(..)
2477 | ExprKind::Unary(..) => ExprPrecedence::Prefix,
2478
2479 ExprKind::Array(_)
2481 | ExprKind::Block(..)
2482 | ExprKind::Call(..)
2483 | ExprKind::ConstBlock(_)
2484 | ExprKind::Continue(..)
2485 | ExprKind::Field(..)
2486 | ExprKind::If(..)
2487 | ExprKind::Index(..)
2488 | ExprKind::InlineAsm(..)
2489 | ExprKind::Lit(_)
2490 | ExprKind::Loop(..)
2491 | ExprKind::Match(..)
2492 | ExprKind::MethodCall(..)
2493 | ExprKind::OffsetOf(..)
2494 | ExprKind::Path(..)
2495 | ExprKind::Repeat(..)
2496 | ExprKind::Struct(..)
2497 | ExprKind::Tup(_)
2498 | ExprKind::Type(..)
2499 | ExprKind::UnsafeBinderCast(..)
2500 | ExprKind::Use(..)
2501 | ExprKind::Err(_) => prefix_attrs_precedence(),
2502
2503 ExprKind::DropTemps(expr, ..) => expr.precedence(has_attr),
2504 }
2505 }
2506
2507 pub fn is_syntactic_place_expr(&self) -> bool {
2512 self.is_place_expr(|_| true)
2513 }
2514
2515 pub fn is_place_expr(&self, mut allow_projections_from: impl FnMut(&Self) -> bool) -> bool {
2520 match self.kind {
2521 ExprKind::Path(QPath::Resolved(_, ref path)) => {
2522 #[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)
2523 }
2524
2525 ExprKind::Type(ref e, _) => e.is_place_expr(allow_projections_from),
2529
2530 ExprKind::UnsafeBinderCast(_, e, _) => e.is_place_expr(allow_projections_from),
2532
2533 ExprKind::Unary(UnOp::Deref, _) => true,
2534
2535 ExprKind::Field(ref base, _) | ExprKind::Index(ref base, _, _) => {
2536 allow_projections_from(base) || base.is_place_expr(allow_projections_from)
2537 }
2538
2539 ExprKind::Err(_guar)
2541 | ExprKind::Let(&LetExpr { recovered: ast::Recovered::Yes(_guar), .. }) => true,
2542
2543 ExprKind::Path(QPath::TypeRelative(..))
2546 | ExprKind::Call(..)
2547 | ExprKind::MethodCall(..)
2548 | ExprKind::Use(..)
2549 | ExprKind::Struct(..)
2550 | ExprKind::Tup(..)
2551 | ExprKind::If(..)
2552 | ExprKind::Match(..)
2553 | ExprKind::Closure { .. }
2554 | ExprKind::Block(..)
2555 | ExprKind::Repeat(..)
2556 | ExprKind::Array(..)
2557 | ExprKind::Break(..)
2558 | ExprKind::Continue(..)
2559 | ExprKind::Ret(..)
2560 | ExprKind::Become(..)
2561 | ExprKind::Let(..)
2562 | ExprKind::Loop(..)
2563 | ExprKind::Assign(..)
2564 | ExprKind::InlineAsm(..)
2565 | ExprKind::OffsetOf(..)
2566 | ExprKind::AssignOp(..)
2567 | ExprKind::Lit(_)
2568 | ExprKind::ConstBlock(..)
2569 | ExprKind::Unary(..)
2570 | ExprKind::AddrOf(..)
2571 | ExprKind::Binary(..)
2572 | ExprKind::Yield(..)
2573 | ExprKind::Cast(..)
2574 | ExprKind::DropTemps(..) => false,
2575 }
2576 }
2577
2578 pub fn range_span(&self) -> Option<Span> {
2581 is_range_literal(self).then(|| self.span.parent_callsite().unwrap())
2582 }
2583
2584 pub fn is_size_lit(&self) -> bool {
2587 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ExprKind::Lit(Lit {
node: LitKind::Int(_,
LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)), ..
}) => true,
_ => false,
}matches!(
2588 self.kind,
2589 ExprKind::Lit(Lit {
2590 node: LitKind::Int(_, LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)),
2591 ..
2592 })
2593 )
2594 }
2595
2596 pub fn peel_drop_temps(&self) -> &Self {
2602 let mut expr = self;
2603 while let ExprKind::DropTemps(inner) = &expr.kind {
2604 expr = inner;
2605 }
2606 expr
2607 }
2608
2609 pub fn peel_blocks(&self) -> &Self {
2610 let mut expr = self;
2611 while let ExprKind::Block(Block { expr: Some(inner), .. }, _) = &expr.kind {
2612 expr = inner;
2613 }
2614 expr
2615 }
2616
2617 pub fn peel_borrows(&self) -> &Self {
2618 let mut expr = self;
2619 while let ExprKind::AddrOf(.., inner) = &expr.kind {
2620 expr = inner;
2621 }
2622 expr
2623 }
2624
2625 pub fn can_have_side_effects(&self) -> bool {
2626 match self.peel_drop_temps().kind {
2627 ExprKind::Path(_) | ExprKind::Lit(_) | ExprKind::OffsetOf(..) | ExprKind::Use(..) => {
2628 false
2629 }
2630 ExprKind::Type(base, _)
2631 | ExprKind::Unary(_, base)
2632 | ExprKind::Field(base, _)
2633 | ExprKind::Index(base, _, _)
2634 | ExprKind::AddrOf(.., base)
2635 | ExprKind::Cast(base, _)
2636 | ExprKind::UnsafeBinderCast(_, base, _) => {
2637 base.can_have_side_effects()
2641 }
2642 ExprKind::Binary(_, lhs, rhs) => {
2643 lhs.can_have_side_effects() || rhs.can_have_side_effects()
2647 }
2648 ExprKind::Struct(_, fields, init) => {
2649 let init_side_effects = match init {
2650 StructTailExpr::Base(init) => init.can_have_side_effects(),
2651 StructTailExpr::DefaultFields(_) | StructTailExpr::None => false,
2652 };
2653 fields.iter().map(|field| field.expr).any(|e| e.can_have_side_effects())
2654 || init_side_effects
2655 }
2656
2657 ExprKind::Array(args)
2658 | ExprKind::Tup(args)
2659 | ExprKind::Call(
2660 Expr {
2661 kind:
2662 ExprKind::Path(QPath::Resolved(
2663 None,
2664 Path { res: Res::Def(DefKind::Ctor(_, CtorKind::Fn), _), .. },
2665 )),
2666 ..
2667 },
2668 args,
2669 ) => args.iter().any(|arg| arg.can_have_side_effects()),
2670 ExprKind::Repeat(arg, _) => arg.can_have_side_effects(),
2671 ExprKind::If(..)
2672 | ExprKind::Match(..)
2673 | ExprKind::MethodCall(..)
2674 | ExprKind::Call(..)
2675 | ExprKind::Closure { .. }
2676 | ExprKind::Block(..)
2677 | ExprKind::Break(..)
2678 | ExprKind::Continue(..)
2679 | ExprKind::Ret(..)
2680 | ExprKind::Become(..)
2681 | ExprKind::Let(..)
2682 | ExprKind::Loop(..)
2683 | ExprKind::Assign(..)
2684 | ExprKind::InlineAsm(..)
2685 | ExprKind::AssignOp(..)
2686 | ExprKind::ConstBlock(..)
2687 | ExprKind::Yield(..)
2688 | ExprKind::DropTemps(..)
2689 | ExprKind::Err(_) => true,
2690 }
2691 }
2692
2693 pub fn is_approximately_pattern(&self) -> bool {
2695 match &self.kind {
2696 ExprKind::Array(_)
2697 | ExprKind::Call(..)
2698 | ExprKind::Tup(_)
2699 | ExprKind::Lit(_)
2700 | ExprKind::Path(_)
2701 | ExprKind::Struct(..) => true,
2702 _ => false,
2703 }
2704 }
2705
2706 pub fn equivalent_for_indexing(&self, other: &Expr<'_>) -> bool {
2711 match (self.kind, other.kind) {
2712 (ExprKind::Lit(lit1), ExprKind::Lit(lit2)) => lit1.node == lit2.node,
2713 (
2714 ExprKind::Path(QPath::Resolved(None, path1)),
2715 ExprKind::Path(QPath::Resolved(None, path2)),
2716 ) => path1.res == path2.res,
2717 (
2718 ExprKind::Struct(
2719 &QPath::Resolved(None, &Path { res: Res::Def(_, path1_def_id), .. }),
2720 args1,
2721 StructTailExpr::None,
2722 ),
2723 ExprKind::Struct(
2724 &QPath::Resolved(None, &Path { res: Res::Def(_, path2_def_id), .. }),
2725 args2,
2726 StructTailExpr::None,
2727 ),
2728 ) => {
2729 path2_def_id == path1_def_id
2730 && is_range_literal(self)
2731 && is_range_literal(other)
2732 && std::iter::zip(args1, args2)
2733 .all(|(a, b)| a.expr.equivalent_for_indexing(b.expr))
2734 }
2735 _ => false,
2736 }
2737 }
2738
2739 pub fn method_ident(&self) -> Option<Ident> {
2740 match self.kind {
2741 ExprKind::MethodCall(receiver_method, ..) => Some(receiver_method.ident),
2742 ExprKind::Unary(_, expr) | ExprKind::AddrOf(.., expr) => expr.method_ident(),
2743 _ => None,
2744 }
2745 }
2746}
2747
2748pub fn is_range_literal(expr: &Expr<'_>) -> bool {
2751 if let ExprKind::Struct(QPath::Resolved(None, path), _, StructTailExpr::None) = expr.kind
2752 && let [.., segment] = path.segments
2753 && let sym::RangeFrom
2754 | sym::RangeFull
2755 | sym::Range
2756 | sym::RangeToInclusive
2757 | sym::RangeTo
2758 | sym::RangeFromCopy
2759 | sym::RangeCopy
2760 | sym::RangeInclusiveCopy
2761 | sym::RangeToInclusiveCopy = segment.ident.name
2762 && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2763 {
2764 true
2765 } else if let ExprKind::Call(func, _) = &expr.kind
2766 && let ExprKind::Path(QPath::Resolved(None, path)) = func.kind
2767 && let [.., segment] = path.segments
2768 && let sym::range_inclusive_new = segment.ident.name
2769 && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2770 {
2771 true
2772 } else {
2773 false
2774 }
2775}
2776
2777pub fn expr_needs_parens(expr: &Expr<'_>) -> bool {
2784 match expr.kind {
2785 ExprKind::Cast(_, _) | ExprKind::Binary(_, _, _) => true,
2787 _ if is_range_literal(expr) => true,
2789 _ => false,
2790 }
2791}
2792
2793#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ExprKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ExprKind::ConstBlock(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ConstBlock", &__self_0),
ExprKind::Array(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Array",
&__self_0),
ExprKind::Call(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Call",
__self_0, &__self_1),
ExprKind::MethodCall(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f,
"MethodCall", __self_0, __self_1, __self_2, &__self_3),
ExprKind::Use(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Use",
__self_0, &__self_1),
ExprKind::Tup(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tup",
&__self_0),
ExprKind::Binary(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Binary",
__self_0, __self_1, &__self_2),
ExprKind::Unary(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Unary",
__self_0, &__self_1),
ExprKind::Lit(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Lit",
&__self_0),
ExprKind::Cast(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Cast",
__self_0, &__self_1),
ExprKind::Type(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Type",
__self_0, &__self_1),
ExprKind::DropTemps(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"DropTemps", &__self_0),
ExprKind::Let(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Let",
&__self_0),
ExprKind::If(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "If",
__self_0, __self_1, &__self_2),
ExprKind::Loop(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f, "Loop",
__self_0, __self_1, __self_2, &__self_3),
ExprKind::Match(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Match",
__self_0, __self_1, &__self_2),
ExprKind::Closure(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Closure", &__self_0),
ExprKind::Block(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Block",
__self_0, &__self_1),
ExprKind::Assign(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Assign",
__self_0, __self_1, &__self_2),
ExprKind::AssignOp(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f,
"AssignOp", __self_0, __self_1, &__self_2),
ExprKind::Field(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Field",
__self_0, &__self_1),
ExprKind::Index(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Index",
__self_0, __self_1, &__self_2),
ExprKind::Path(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
&__self_0),
ExprKind::AddrOf(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "AddrOf",
__self_0, __self_1, &__self_2),
ExprKind::Break(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Break",
__self_0, &__self_1),
ExprKind::Continue(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Continue", &__self_0),
ExprKind::Ret(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ret",
&__self_0),
ExprKind::Become(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Become",
&__self_0),
ExprKind::InlineAsm(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"InlineAsm", &__self_0),
ExprKind::OffsetOf(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"OffsetOf", __self_0, &__self_1),
ExprKind::Struct(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Struct",
__self_0, __self_1, &__self_2),
ExprKind::Repeat(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Repeat",
__self_0, &__self_1),
ExprKind::Yield(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Yield",
__self_0, &__self_1),
ExprKind::UnsafeBinderCast(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f,
"UnsafeBinderCast", __self_0, __self_1, &__self_2),
ExprKind::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ExprKind<'hir> {
#[inline]
fn clone(&self) -> ExprKind<'hir> {
let _: ::core::clone::AssertParamIsClone<ConstBlock>;
let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir PathSegment<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
let _: ::core::clone::AssertParamIsClone<BinOp>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<UnOp>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Lit>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir LetExpr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<Label>>;
let _: ::core::clone::AssertParamIsClone<LoopSource>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Arm<'hir>]>;
let _: ::core::clone::AssertParamIsClone<MatchSource>;
let _: ::core::clone::AssertParamIsClone<&'hir Closure<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<Label>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<AssignOp>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
let _: ::core::clone::AssertParamIsClone<BorrowKind>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Destination>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir InlineAsm<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Ident]>;
let _: ::core::clone::AssertParamIsClone<&'hir QPath<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [ExprField<'hir>]>;
let _: ::core::clone::AssertParamIsClone<StructTailExpr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<YieldSource>;
let _: ::core::clone::AssertParamIsClone<UnsafeBinderCastKind>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
let _: ::core::clone::AssertParamIsClone<rustc_span::ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ExprKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ExprKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ExprKind::ConstBlock(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Array(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Call(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::MethodCall(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
ExprKind::Use(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Tup(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Binary(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Unary(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Lit(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Cast(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Type(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::DropTemps(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Let(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::If(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Loop(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
ExprKind::Match(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Closure(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Block(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Assign(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::AssignOp(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Field(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Index(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Path(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::AddrOf(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Break(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Continue(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Ret(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::Become(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::InlineAsm(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExprKind::OffsetOf(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Struct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Repeat(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::Yield(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExprKind::UnsafeBinderCast(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ExprKind::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2794pub enum ExprKind<'hir> {
2795 ConstBlock(ConstBlock),
2797 Array(&'hir [Expr<'hir>]),
2799 Call(&'hir Expr<'hir>, &'hir [Expr<'hir>]),
2806 MethodCall(&'hir PathSegment<'hir>, &'hir Expr<'hir>, &'hir [Expr<'hir>], Span),
2823 Use(&'hir Expr<'hir>, Span),
2825 Tup(&'hir [Expr<'hir>]),
2827 Binary(BinOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2829 Unary(UnOp, &'hir Expr<'hir>),
2831 Lit(Lit),
2833 Cast(&'hir Expr<'hir>, &'hir Ty<'hir>),
2835 Type(&'hir Expr<'hir>, &'hir Ty<'hir>),
2837 DropTemps(&'hir Expr<'hir>),
2843 Let(&'hir LetExpr<'hir>),
2848 If(&'hir Expr<'hir>, &'hir Expr<'hir>, Option<&'hir Expr<'hir>>),
2857 Loop(&'hir Block<'hir>, Option<Label>, LoopSource, Span),
2863 Match(&'hir Expr<'hir>, &'hir [Arm<'hir>], MatchSource),
2866 Closure(&'hir Closure<'hir>),
2873 Block(&'hir Block<'hir>, Option<Label>),
2875
2876 Assign(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
2878 AssignOp(AssignOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2882 Field(&'hir Expr<'hir>, Ident),
2884 Index(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
2888
2889 Path(QPath<'hir>),
2891
2892 AddrOf(BorrowKind, Mutability, &'hir Expr<'hir>),
2894 Break(Destination, Option<&'hir Expr<'hir>>),
2896 Continue(Destination),
2898 Ret(Option<&'hir Expr<'hir>>),
2900 Become(&'hir Expr<'hir>),
2902
2903 InlineAsm(&'hir InlineAsm<'hir>),
2905
2906 OffsetOf(&'hir Ty<'hir>, &'hir [Ident]),
2908
2909 Struct(&'hir QPath<'hir>, &'hir [ExprField<'hir>], StructTailExpr<'hir>),
2914
2915 Repeat(&'hir Expr<'hir>, &'hir ConstArg<'hir>),
2920
2921 Yield(&'hir Expr<'hir>, YieldSource),
2923
2924 UnsafeBinderCast(UnsafeBinderCastKind, &'hir Expr<'hir>, Option<&'hir Ty<'hir>>),
2927
2928 Err(rustc_span::ErrorGuaranteed),
2930}
2931
2932#[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),
}
}
}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>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for StructTailExpr<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
StructTailExpr<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
StructTailExpr::None => {}
StructTailExpr::Base(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
StructTailExpr::DefaultFields(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2933pub enum StructTailExpr<'hir> {
2934 None,
2936 Base(&'hir Expr<'hir>),
2939 DefaultFields(Span),
2943}
2944
2945#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for QPath<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
QPath::Resolved(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"Resolved", __self_0, &__self_1),
QPath::TypeRelative(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"TypeRelative", __self_0, &__self_1),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for QPath<'hir> {
#[inline]
fn clone(&self) -> QPath<'hir> {
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Path<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir PathSegment<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for QPath<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
QPath<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
QPath::Resolved(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
QPath::TypeRelative(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
2951pub enum QPath<'hir> {
2952 Resolved(Option<&'hir Ty<'hir>>, &'hir Path<'hir>),
2959
2960 TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
2967}
2968
2969impl<'hir> QPath<'hir> {
2970 pub fn span(&self) -> Span {
2972 match *self {
2973 QPath::Resolved(_, path) => path.span,
2974 QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
2975 }
2976 }
2977
2978 pub fn qself_span(&self) -> Span {
2981 match *self {
2982 QPath::Resolved(_, path) => path.span,
2983 QPath::TypeRelative(qself, _) => qself.span,
2984 }
2985 }
2986}
2987
2988#[derive(#[automatically_derived]
impl ::core::marker::Copy for LocalSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LocalSource {
#[inline]
fn clone(&self) -> LocalSource { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for LocalSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
LocalSource::Normal => "Normal",
LocalSource::AsyncFn => "AsyncFn",
LocalSource::AwaitDesugar => "AwaitDesugar",
LocalSource::AssignDesugar => "AssignDesugar",
LocalSource::Contract => "Contract",
})
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LocalSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LocalSource::Normal => {}
LocalSource::AsyncFn => {}
LocalSource::AwaitDesugar => {}
LocalSource::AssignDesugar => {}
LocalSource::Contract => {}
}
}
}
};HashStable_Generic)]
2990pub enum LocalSource {
2991 Normal,
2993 AsyncFn,
3004 AwaitDesugar,
3006 AssignDesugar,
3008 Contract,
3010}
3011
3012#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<HirId>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for MatchSource {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
MatchSource::TryDesugar(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for MatchSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
MatchSource::Normal =>
::core::fmt::Formatter::write_str(f, "Normal"),
MatchSource::Postfix =>
::core::fmt::Formatter::write_str(f, "Postfix"),
MatchSource::ForLoopDesugar =>
::core::fmt::Formatter::write_str(f, "ForLoopDesugar"),
MatchSource::TryDesugar(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TryDesugar", &__self_0),
MatchSource::AwaitDesugar =>
::core::fmt::Formatter::write_str(f, "AwaitDesugar"),
MatchSource::FormatArgs =>
::core::fmt::Formatter::write_str(f, "FormatArgs"),
}
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for MatchSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
MatchSource::Normal => {}
MatchSource::Postfix => {}
MatchSource::ForLoopDesugar => {}
MatchSource::TryDesugar(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
MatchSource::AwaitDesugar => {}
MatchSource::FormatArgs => {}
}
}
}
};HashStable_Generic, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for MatchSource {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
MatchSource::Normal => { 0usize }
MatchSource::Postfix => { 1usize }
MatchSource::ForLoopDesugar => { 2usize }
MatchSource::TryDesugar(ref __binding_0) => { 3usize }
MatchSource::AwaitDesugar => { 4usize }
MatchSource::FormatArgs => { 5usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
MatchSource::Normal => {}
MatchSource::Postfix => {}
MatchSource::ForLoopDesugar => {}
MatchSource::TryDesugar(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
MatchSource::AwaitDesugar => {}
MatchSource::FormatArgs => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for MatchSource {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { MatchSource::Normal }
1usize => { MatchSource::Postfix }
2usize => { MatchSource::ForLoopDesugar }
3usize => {
MatchSource::TryDesugar(::rustc_serialize::Decodable::decode(__decoder))
}
4usize => { MatchSource::AwaitDesugar }
5usize => { MatchSource::FormatArgs }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `MatchSource`, expected 0..6, actual {0}",
n));
}
}
}
}
};Decodable)]
3014pub enum MatchSource {
3015 Normal,
3017 Postfix,
3019 ForLoopDesugar,
3021 TryDesugar(HirId),
3023 AwaitDesugar,
3025 FormatArgs,
3027}
3028
3029impl MatchSource {
3030 #[inline]
3031 pub const fn name(self) -> &'static str {
3032 use MatchSource::*;
3033 match self {
3034 Normal => "match",
3035 Postfix => ".match",
3036 ForLoopDesugar => "for",
3037 TryDesugar(_) => "?",
3038 AwaitDesugar => ".await",
3039 FormatArgs => "format_args!()",
3040 }
3041 }
3042}
3043
3044#[derive(#[automatically_derived]
impl ::core::marker::Copy for LoopSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LoopSource {
#[inline]
fn clone(&self) -> LoopSource { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LoopSource {
#[inline]
fn eq(&self, other: &LoopSource) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for LoopSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
LoopSource::Loop => "Loop",
LoopSource::While => "While",
LoopSource::ForLoop => "ForLoop",
})
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LoopSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LoopSource::Loop => {}
LoopSource::While => {}
LoopSource::ForLoop => {}
}
}
}
};HashStable_Generic)]
3046pub enum LoopSource {
3047 Loop,
3049 While,
3051 ForLoop,
3053}
3054
3055impl LoopSource {
3056 pub fn name(self) -> &'static str {
3057 match self {
3058 LoopSource::Loop => "loop",
3059 LoopSource::While => "while",
3060 LoopSource::ForLoop => "for",
3061 }
3062 }
3063}
3064
3065#[derive(#[automatically_derived]
impl ::core::marker::Copy for LoopIdError { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LoopIdError {
#[inline]
fn clone(&self) -> LoopIdError { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for LoopIdError {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
LoopIdError::OutsideLoopScope => "OutsideLoopScope",
LoopIdError::UnlabeledCfInWhileCondition =>
"UnlabeledCfInWhileCondition",
LoopIdError::UnresolvedLabel => "UnresolvedLabel",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for LoopIdError {
#[inline]
fn eq(&self, other: &LoopIdError) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for LoopIdError where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
LoopIdError::OutsideLoopScope => {}
LoopIdError::UnlabeledCfInWhileCondition => {}
LoopIdError::UnresolvedLabel => {}
}
}
}
};HashStable_Generic)]
3066pub enum LoopIdError {
3067 OutsideLoopScope,
3068 UnlabeledCfInWhileCondition,
3069 UnresolvedLabel,
3070}
3071
3072impl fmt::Display for LoopIdError {
3073 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3074 f.write_str(match self {
3075 LoopIdError::OutsideLoopScope => "not inside loop scope",
3076 LoopIdError::UnlabeledCfInWhileCondition => {
3077 "unlabeled control flow (break or continue) in while condition"
3078 }
3079 LoopIdError::UnresolvedLabel => "label not found",
3080 })
3081 }
3082}
3083
3084#[derive(#[automatically_derived]
impl ::core::marker::Copy for Destination { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Destination {
#[inline]
fn clone(&self) -> Destination {
let _: ::core::clone::AssertParamIsClone<Option<Label>>;
let _: ::core::clone::AssertParamIsClone<Result<HirId, LoopIdError>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Destination {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Destination",
"label", &self.label, "target_id", &&self.target_id)
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for Destination {
#[inline]
fn eq(&self, other: &Destination) -> bool {
self.label == other.label && self.target_id == other.target_id
}
}PartialEq, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Destination where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Destination {
label: ref __binding_0, target_id: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3085pub struct Destination {
3086 pub label: Option<Label>,
3088
3089 pub target_id: Result<HirId, LoopIdError>,
3092}
3093
3094#[derive(#[automatically_derived]
impl ::core::marker::Copy for YieldSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for YieldSource {
#[inline]
fn clone(&self) -> YieldSource {
let _: ::core::clone::AssertParamIsClone<Option<HirId>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for YieldSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
YieldSource::Await { expr: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Await",
"expr", &__self_0),
YieldSource::Yield =>
::core::fmt::Formatter::write_str(f, "Yield"),
}
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for YieldSource where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
YieldSource::Await { expr: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
YieldSource::Yield => {}
}
}
}
};HashStable_Generic)]
3096pub enum YieldSource {
3097 Await { expr: Option<HirId> },
3099 Yield,
3101}
3102
3103impl fmt::Display for YieldSource {
3104 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3105 f.write_str(match self {
3106 YieldSource::Await { .. } => "`await`",
3107 YieldSource::Yield => "`yield`",
3108 })
3109 }
3110}
3111
3112#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for MutTy<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "MutTy", "ty",
&self.ty, "mutbl", &&self.mutbl)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for MutTy<'hir> {
#[inline]
fn clone(&self) -> MutTy<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for MutTy<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
MutTy<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
MutTy { ty: ref __binding_0, mutbl: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3115pub struct MutTy<'hir> {
3116 pub ty: &'hir Ty<'hir>,
3117 pub mutbl: Mutability,
3118}
3119
3120#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnSig<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "FnSig",
"header", &self.header, "decl", &self.decl, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnSig<'hir> {
#[inline]
fn clone(&self) -> FnSig<'hir> {
let _: ::core::clone::AssertParamIsClone<FnHeader>;
let _: ::core::clone::AssertParamIsClone<&'hir FnDecl<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnSig<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnSig<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FnSig {
header: ref __binding_0,
decl: ref __binding_1,
span: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3123pub struct FnSig<'hir> {
3124 pub header: FnHeader,
3125 pub decl: &'hir FnDecl<'hir>,
3126 pub span: Span,
3127}
3128
3129#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<OwnerId>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for TraitItemId {
fn encode(&self, __encoder: &mut __E) {
match *self {
TraitItemId { owner_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for TraitItemId {
fn decode(__decoder: &mut __D) -> Self {
TraitItemId {
owner_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for TraitItemId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "TraitItemId",
"owner_id", &&self.owner_id)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for TraitItemId where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitItemId { owner_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3133pub struct TraitItemId {
3134 pub owner_id: OwnerId,
3135}
3136
3137impl TraitItemId {
3138 #[inline]
3139 pub fn hir_id(&self) -> HirId {
3140 HirId::make_owner(self.owner_id.def_id)
3142 }
3143}
3144
3145#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitItem<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["ident", "owner_id", "generics", "kind", "span", "defaultness",
"has_delayed_lints"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.owner_id, &self.generics, &self.kind,
&self.span, &self.defaultness, &&self.has_delayed_lints];
::core::fmt::Formatter::debug_struct_fields_finish(f, "TraitItem",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitItem<'hir> {
#[inline]
fn clone(&self) -> TraitItem<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<OwnerId>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<TraitItemKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Defaultness>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitItem<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitItem<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitItem {
ident: ref __binding_0,
owner_id: ref __binding_1,
generics: ref __binding_2,
kind: ref __binding_3,
span: ref __binding_4,
defaultness: ref __binding_5,
has_delayed_lints: ref __binding_6 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3150pub struct TraitItem<'hir> {
3151 pub ident: Ident,
3152 pub owner_id: OwnerId,
3153 pub generics: &'hir Generics<'hir>,
3154 pub kind: TraitItemKind<'hir>,
3155 pub span: Span,
3156 pub defaultness: Defaultness,
3157 pub has_delayed_lints: bool,
3158}
3159
3160macro_rules! expect_methods_self_kind {
3161 ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3162 $(
3163 #[track_caller]
3164 pub fn $name(&self) -> $ret_ty {
3165 let $pat = &self.kind else { expect_failed(stringify!($name), self) };
3166 $ret_val
3167 }
3168 )*
3169 }
3170}
3171
3172macro_rules! expect_methods_self {
3173 ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3174 $(
3175 #[track_caller]
3176 pub fn $name(&self) -> $ret_ty {
3177 let $pat = self else { expect_failed(stringify!($name), self) };
3178 $ret_val
3179 }
3180 )*
3181 }
3182}
3183
3184#[track_caller]
3185fn expect_failed<T: fmt::Debug>(ident: &'static str, found: T) -> ! {
3186 {
::core::panicking::panic_fmt(format_args!("{0}: found {1:?}", ident,
found));
}panic!("{ident}: found {found:?}")
3187}
3188
3189impl<'hir> TraitItem<'hir> {
3190 #[inline]
3191 pub fn hir_id(&self) -> HirId {
3192 HirId::make_owner(self.owner_id.def_id)
3194 }
3195
3196 pub fn trait_item_id(&self) -> TraitItemId {
3197 TraitItemId { owner_id: self.owner_id }
3198 }
3199
3200 self
let TraitItemKind::Type(bounds, ty) =
&self.kind else { expect_failed("expect_type", self) };
(bounds, *ty);expect_methods_self_kind! {
3201 expect_const, (&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>),
3202 TraitItemKind::Const(ty, rhs), (ty, *rhs);
3203
3204 expect_fn, (&FnSig<'hir>, &TraitFn<'hir>),
3205 TraitItemKind::Fn(ty, trfn), (ty, trfn);
3206
3207 expect_type, (GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3208 TraitItemKind::Type(bounds, ty), (bounds, *ty);
3209 }
3210}
3211
3212#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitFn<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TraitFn::Required(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Required", &__self_0),
TraitFn::Provided(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Provided", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitFn<'hir> {
#[inline]
fn clone(&self) -> TraitFn<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [Option<Ident>]>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitFn<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitFn<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
TraitFn::Required(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TraitFn::Provided(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3214pub enum TraitFn<'hir> {
3215 Required(&'hir [Option<Ident>]),
3217
3218 Provided(BodyId),
3220}
3221
3222#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitItemKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TraitItemKind::Const(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Const",
__self_0, &__self_1),
TraitItemKind::Fn(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Fn",
__self_0, &__self_1),
TraitItemKind::Type(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Type",
__self_0, &__self_1),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitItemKind<'hir> {
#[inline]
fn clone(&self) -> TraitItemKind<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<ConstItemRhs<'hir>>>;
let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
let _: ::core::clone::AssertParamIsClone<TraitFn<'hir>>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitItemKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitItemKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
TraitItemKind::Const(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.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)]
3224pub enum TraitItemKind<'hir> {
3225 Const(&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>),
3227 Fn(FnSig<'hir>, TraitFn<'hir>),
3229 Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3232}
3233
3234#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<OwnerId>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ImplItemId {
fn encode(&self, __encoder: &mut __E) {
match *self {
ImplItemId { owner_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ImplItemId {
fn decode(__decoder: &mut __D) -> Self {
ImplItemId {
owner_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ImplItemId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "ImplItemId",
"owner_id", &&self.owner_id)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ImplItemId where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ImplItemId { owner_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3238pub struct ImplItemId {
3239 pub owner_id: OwnerId,
3240}
3241
3242impl ImplItemId {
3243 #[inline]
3244 pub fn hir_id(&self) -> HirId {
3245 HirId::make_owner(self.owner_id.def_id)
3247 }
3248}
3249
3250#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ImplItem<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["ident", "owner_id", "generics", "kind", "impl_kind", "span",
"has_delayed_lints"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.owner_id, &self.generics, &self.kind,
&self.impl_kind, &self.span, &&self.has_delayed_lints];
::core::fmt::Formatter::debug_struct_fields_finish(f, "ImplItem",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ImplItem<'hir> {
#[inline]
fn clone(&self) -> ImplItem<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<OwnerId>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<ImplItemKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<ImplItemImplKind>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ImplItem<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ImplItem<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ImplItem {
ident: ref __binding_0,
owner_id: ref __binding_1,
generics: ref __binding_2,
kind: ref __binding_3,
impl_kind: ref __binding_4,
span: ref __binding_5,
has_delayed_lints: ref __binding_6 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3254pub struct ImplItem<'hir> {
3255 pub ident: Ident,
3256 pub owner_id: OwnerId,
3257 pub generics: &'hir Generics<'hir>,
3258 pub kind: ImplItemKind<'hir>,
3259 pub impl_kind: ImplItemImplKind,
3260 pub span: Span,
3261 pub has_delayed_lints: bool,
3262}
3263
3264#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ImplItemImplKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ImplItemImplKind::Inherent { vis_span: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Inherent", "vis_span", &__self_0),
ImplItemImplKind::Trait {
defaultness: __self_0, trait_item_def_id: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Trait",
"defaultness", __self_0, "trait_item_def_id", &__self_1),
}
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for ImplItemImplKind {
#[inline]
fn clone(&self) -> ImplItemImplKind {
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Defaultness>;
let _:
::core::clone::AssertParamIsClone<Result<DefId,
ErrorGuaranteed>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ImplItemImplKind { }Copy, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ImplItemImplKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ImplItemImplKind::Inherent { vis_span: ref __binding_0 } =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ImplItemImplKind::Trait {
defaultness: ref __binding_0,
trait_item_def_id: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3265pub enum ImplItemImplKind {
3266 Inherent {
3267 vis_span: Span,
3268 },
3269 Trait {
3270 defaultness: Defaultness,
3271 trait_item_def_id: Result<DefId, ErrorGuaranteed>,
3273 },
3274}
3275
3276impl<'hir> ImplItem<'hir> {
3277 #[inline]
3278 pub fn hir_id(&self) -> HirId {
3279 HirId::make_owner(self.owner_id.def_id)
3281 }
3282
3283 pub fn impl_item_id(&self) -> ImplItemId {
3284 ImplItemId { owner_id: self.owner_id }
3285 }
3286
3287 pub fn vis_span(&self) -> Option<Span> {
3288 match self.impl_kind {
3289 ImplItemImplKind::Trait { .. } => None,
3290 ImplItemImplKind::Inherent { vis_span, .. } => Some(vis_span),
3291 }
3292 }
3293
3294 self
let ImplItemKind::Type(ty) =
&self.kind else { expect_failed("expect_type", self) };
ty;expect_methods_self_kind! {
3295 expect_const, (&'hir Ty<'hir>, ConstItemRhs<'hir>), ImplItemKind::Const(ty, rhs), (ty, *rhs);
3296 expect_fn, (&FnSig<'hir>, BodyId), ImplItemKind::Fn(ty, body), (ty, *body);
3297 expect_type, &'hir Ty<'hir>, ImplItemKind::Type(ty), ty;
3298 }
3299}
3300
3301#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ImplItemKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ImplItemKind::Const(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Const",
__self_0, &__self_1),
ImplItemKind::Fn(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Fn",
__self_0, &__self_1),
ImplItemKind::Type(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Type",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ImplItemKind<'hir> {
#[inline]
fn clone(&self) -> ImplItemKind<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<ConstItemRhs<'hir>>;
let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ImplItemKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ImplItemKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ImplItemKind::Const(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ImplItemKind::Fn(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ImplItemKind::Type(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3303pub enum ImplItemKind<'hir> {
3304 Const(&'hir Ty<'hir>, ConstItemRhs<'hir>),
3307 Fn(FnSig<'hir>, BodyId),
3309 Type(&'hir Ty<'hir>),
3311}
3312
3313#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for AssocItemConstraint<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f,
"AssocItemConstraint", "hir_id", &self.hir_id, "ident",
&self.ident, "gen_args", &self.gen_args, "kind", &self.kind,
"span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for AssocItemConstraint<'hir> {
#[inline]
fn clone(&self) -> AssocItemConstraint<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir GenericArgs<'hir>>;
let _:
::core::clone::AssertParamIsClone<AssocItemConstraintKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for AssocItemConstraint<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
AssocItemConstraint<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
AssocItemConstraint {
hir_id: ref __binding_0,
ident: ref __binding_1,
gen_args: ref __binding_2,
kind: ref __binding_3,
span: ref __binding_4 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3324pub struct AssocItemConstraint<'hir> {
3325 #[stable_hasher(ignore)]
3326 pub hir_id: HirId,
3327 pub ident: Ident,
3328 pub gen_args: &'hir GenericArgs<'hir>,
3329 pub kind: AssocItemConstraintKind<'hir>,
3330 pub span: Span,
3331}
3332
3333impl<'hir> AssocItemConstraint<'hir> {
3334 pub fn ty(self) -> Option<&'hir Ty<'hir>> {
3336 match self.kind {
3337 AssocItemConstraintKind::Equality { term: Term::Ty(ty) } => Some(ty),
3338 _ => None,
3339 }
3340 }
3341
3342 pub fn ct(self) -> Option<&'hir ConstArg<'hir>> {
3344 match self.kind {
3345 AssocItemConstraintKind::Equality { term: Term::Const(ct) } => Some(ct),
3346 _ => None,
3347 }
3348 }
3349}
3350
3351#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Term<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Term::Ty(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ty",
&__self_0),
Term::Const(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Term<'hir> {
#[inline]
fn clone(&self) -> Term<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Term<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Term<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Term::Ty(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Term::Const(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3352pub enum Term<'hir> {
3353 Ty(&'hir Ty<'hir>),
3354 Const(&'hir ConstArg<'hir>),
3355}
3356
3357impl<'hir> From<&'hir Ty<'hir>> for Term<'hir> {
3358 fn from(ty: &'hir Ty<'hir>) -> Self {
3359 Term::Ty(ty)
3360 }
3361}
3362
3363impl<'hir> From<&'hir ConstArg<'hir>> for Term<'hir> {
3364 fn from(c: &'hir ConstArg<'hir>) -> Self {
3365 Term::Const(c)
3366 }
3367}
3368
3369#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for AssocItemConstraintKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
AssocItemConstraintKind::Equality { term: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Equality", "term", &__self_0),
AssocItemConstraintKind::Bound { bounds: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Bound",
"bounds", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for AssocItemConstraintKind<'hir> {
#[inline]
fn clone(&self) -> AssocItemConstraintKind<'hir> {
let _: ::core::clone::AssertParamIsClone<Term<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [GenericBound<'hir>]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for AssocItemConstraintKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
AssocItemConstraintKind<'hir> where
__CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
AssocItemConstraintKind::Equality { term: ref __binding_0 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
AssocItemConstraintKind::Bound { bounds: ref __binding_0 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3371pub enum AssocItemConstraintKind<'hir> {
3372 Equality { term: Term<'hir> },
3379 Bound { bounds: &'hir [GenericBound<'hir>] },
3381}
3382
3383impl<'hir> AssocItemConstraintKind<'hir> {
3384 pub fn descr(&self) -> &'static str {
3385 match self {
3386 AssocItemConstraintKind::Equality { .. } => "binding",
3387 AssocItemConstraintKind::Bound { .. } => "constraint",
3388 }
3389 }
3390}
3391
3392#[derive(#[automatically_derived]
impl ::core::fmt::Debug for AmbigArg {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match *self {}
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for AmbigArg {
#[inline]
fn clone(&self) -> AmbigArg { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for AmbigArg { }Copy, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for AmbigArg where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {}
}
}
};HashStable_Generic)]
3396pub enum AmbigArg {}
3397
3398#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
Ty<'hir, Unambig> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "Ty", "hir_id",
&self.hir_id, "span", &self.span, "kind", &&self.kind)
}
}Debug, #[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
Ty<'hir, Unambig> {
#[inline]
fn clone(&self) -> Ty<'hir, Unambig> {
Ty {
hir_id: ::core::clone::Clone::clone(&self.hir_id),
span: ::core::clone::Clone::clone(&self.span),
kind: ::core::clone::Clone::clone(&self.kind),
}
}
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
Ty<'hir, Unambig> {
}Copy, const _: () =
{
impl<'hir, Unambig, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Ty<'hir, Unambig> where __CTX: crate::HashStableContext,
Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Ty {
hir_id: ref __binding_0,
span: ref __binding_1,
kind: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3403#[repr(C)]
3404pub struct Ty<'hir, Unambig = ()> {
3405 #[stable_hasher(ignore)]
3406 pub hir_id: HirId,
3407 pub span: Span,
3408 pub kind: TyKind<'hir, Unambig>,
3409}
3410
3411impl<'hir> Ty<'hir, AmbigArg> {
3412 pub fn as_unambig_ty(&self) -> &Ty<'hir> {
3423 let ptr = self as *const Ty<'hir, AmbigArg> as *const Ty<'hir, ()>;
3426 unsafe { &*ptr }
3427 }
3428}
3429
3430impl<'hir> Ty<'hir> {
3431 pub fn try_as_ambig_ty(&self) -> Option<&Ty<'hir, AmbigArg>> {
3437 if let TyKind::Infer(()) = self.kind {
3438 return None;
3439 }
3440
3441 let ptr = self as *const Ty<'hir> as *const Ty<'hir, AmbigArg>;
3445 Some(unsafe { &*ptr })
3446 }
3447}
3448
3449impl<'hir> Ty<'hir, AmbigArg> {
3450 pub fn peel_refs(&self) -> &Ty<'hir> {
3451 let mut final_ty = self.as_unambig_ty();
3452 while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3453 final_ty = ty;
3454 }
3455 final_ty
3456 }
3457}
3458
3459impl<'hir> Ty<'hir> {
3460 pub fn peel_refs(&self) -> &Self {
3461 let mut final_ty = self;
3462 while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3463 final_ty = ty;
3464 }
3465 final_ty
3466 }
3467
3468 pub fn as_generic_param(&self) -> Option<(DefId, Ident)> {
3470 let TyKind::Path(QPath::Resolved(None, path)) = self.kind else {
3471 return None;
3472 };
3473 let [segment] = &path.segments else {
3474 return None;
3475 };
3476 match path.res {
3477 Res::Def(DefKind::TyParam, def_id) | Res::SelfTyParam { trait_: def_id } => {
3478 Some((def_id, segment.ident))
3479 }
3480 _ => None,
3481 }
3482 }
3483
3484 pub fn find_self_aliases(&self) -> Vec<Span> {
3485 use crate::intravisit::Visitor;
3486 struct MyVisitor(Vec<Span>);
3487 impl<'v> Visitor<'v> for MyVisitor {
3488 fn visit_ty(&mut self, t: &'v Ty<'v, AmbigArg>) {
3489 if #[allow(non_exhaustive_omitted_patterns)] match &t.kind {
TyKind::Path(QPath::Resolved(_, Path {
res: crate::def::Res::SelfTyAlias { .. }, .. })) => true,
_ => false,
}matches!(
3490 &t.kind,
3491 TyKind::Path(QPath::Resolved(
3492 _,
3493 Path { res: crate::def::Res::SelfTyAlias { .. }, .. },
3494 ))
3495 ) {
3496 self.0.push(t.span);
3497 return;
3498 }
3499 crate::intravisit::walk_ty(self, t);
3500 }
3501 }
3502
3503 let mut my_visitor = MyVisitor(::alloc::vec::Vec::new()vec![]);
3504 my_visitor.visit_ty_unambig(self);
3505 my_visitor.0
3506 }
3507
3508 pub fn is_suggestable_infer_ty(&self) -> bool {
3511 fn are_suggestable_generic_args(generic_args: &[GenericArg<'_>]) -> bool {
3512 generic_args.iter().any(|arg| match arg {
3513 GenericArg::Type(ty) => ty.as_unambig_ty().is_suggestable_infer_ty(),
3514 GenericArg::Infer(_) => true,
3515 _ => false,
3516 })
3517 }
3518 {
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:3518",
"rustc_hir::hir", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir/src/hir.rs"),
::tracing_core::__macro_support::Option::Some(3518u32),
::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);
3519 match &self.kind {
3520 TyKind::Infer(()) => true,
3521 TyKind::Slice(ty) => ty.is_suggestable_infer_ty(),
3522 TyKind::Array(ty, length) => {
3523 ty.is_suggestable_infer_ty() || #[allow(non_exhaustive_omitted_patterns)] match length.kind {
ConstArgKind::Infer(..) => true,
_ => false,
}matches!(length.kind, ConstArgKind::Infer(..))
3524 }
3525 TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
3526 TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),
3527 TyKind::Path(QPath::TypeRelative(ty, segment)) => {
3528 ty.is_suggestable_infer_ty() || are_suggestable_generic_args(segment.args().args)
3529 }
3530 TyKind::Path(QPath::Resolved(ty_opt, Path { segments, .. })) => {
3531 ty_opt.is_some_and(Self::is_suggestable_infer_ty)
3532 || segments
3533 .iter()
3534 .any(|segment| are_suggestable_generic_args(segment.args().args))
3535 }
3536 _ => false,
3537 }
3538 }
3539}
3540
3541#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<IntTy>;
let _: ::core::cmp::AssertParamIsEq<UintTy>;
let _: ::core::cmp::AssertParamIsEq<FloatTy>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for PrimTy {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
PrimTy::Int(ref __binding_0) => { 0usize }
PrimTy::Uint(ref __binding_0) => { 1usize }
PrimTy::Float(ref __binding_0) => { 2usize }
PrimTy::Str => { 3usize }
PrimTy::Bool => { 4usize }
PrimTy::Char => { 5usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
PrimTy::Int(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
PrimTy::Uint(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
PrimTy::Float(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
PrimTy::Str => {}
PrimTy::Bool => {}
PrimTy::Char => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for PrimTy {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
PrimTy::Int(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
PrimTy::Uint(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => {
PrimTy::Float(::rustc_serialize::Decodable::decode(__decoder))
}
3usize => { PrimTy::Str }
4usize => { PrimTy::Bool }
5usize => { PrimTy::Char }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `PrimTy`, expected 0..6, actual {0}",
n));
}
}
}
}
};Decodable, #[automatically_derived]
impl ::core::hash::Hash for PrimTy {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
PrimTy::Int(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
PrimTy::Uint(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
PrimTy::Float(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for PrimTy {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
PrimTy::Int(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Int",
&__self_0),
PrimTy::Uint(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Uint",
&__self_0),
PrimTy::Float(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Float",
&__self_0),
PrimTy::Str => ::core::fmt::Formatter::write_str(f, "Str"),
PrimTy::Bool => ::core::fmt::Formatter::write_str(f, "Bool"),
PrimTy::Char => ::core::fmt::Formatter::write_str(f, "Char"),
}
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for PrimTy where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
PrimTy::Int(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PrimTy::Uint(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PrimTy::Float(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PrimTy::Str => {}
PrimTy::Bool => {}
PrimTy::Char => {}
}
}
}
};HashStable_Generic)]
3543pub enum PrimTy {
3544 Int(IntTy),
3545 Uint(UintTy),
3546 Float(FloatTy),
3547 Str,
3548 Bool,
3549 Char,
3550}
3551
3552impl PrimTy {
3553 pub const ALL: [Self; 19] = [
3555 Self::Int(IntTy::I8),
3557 Self::Int(IntTy::I16),
3558 Self::Int(IntTy::I32),
3559 Self::Int(IntTy::I64),
3560 Self::Int(IntTy::I128),
3561 Self::Int(IntTy::Isize),
3562 Self::Uint(UintTy::U8),
3563 Self::Uint(UintTy::U16),
3564 Self::Uint(UintTy::U32),
3565 Self::Uint(UintTy::U64),
3566 Self::Uint(UintTy::U128),
3567 Self::Uint(UintTy::Usize),
3568 Self::Float(FloatTy::F16),
3569 Self::Float(FloatTy::F32),
3570 Self::Float(FloatTy::F64),
3571 Self::Float(FloatTy::F128),
3572 Self::Bool,
3573 Self::Char,
3574 Self::Str,
3575 ];
3576
3577 pub fn name_str(self) -> &'static str {
3581 match self {
3582 PrimTy::Int(i) => i.name_str(),
3583 PrimTy::Uint(u) => u.name_str(),
3584 PrimTy::Float(f) => f.name_str(),
3585 PrimTy::Str => "str",
3586 PrimTy::Bool => "bool",
3587 PrimTy::Char => "char",
3588 }
3589 }
3590
3591 pub fn name(self) -> Symbol {
3592 match self {
3593 PrimTy::Int(i) => i.name(),
3594 PrimTy::Uint(u) => u.name(),
3595 PrimTy::Float(f) => f.name(),
3596 PrimTy::Str => sym::str,
3597 PrimTy::Bool => sym::bool,
3598 PrimTy::Char => sym::char,
3599 }
3600 }
3601
3602 pub fn from_name(name: Symbol) -> Option<Self> {
3605 let ty = match name {
3606 sym::i8 => Self::Int(IntTy::I8),
3608 sym::i16 => Self::Int(IntTy::I16),
3609 sym::i32 => Self::Int(IntTy::I32),
3610 sym::i64 => Self::Int(IntTy::I64),
3611 sym::i128 => Self::Int(IntTy::I128),
3612 sym::isize => Self::Int(IntTy::Isize),
3613 sym::u8 => Self::Uint(UintTy::U8),
3614 sym::u16 => Self::Uint(UintTy::U16),
3615 sym::u32 => Self::Uint(UintTy::U32),
3616 sym::u64 => Self::Uint(UintTy::U64),
3617 sym::u128 => Self::Uint(UintTy::U128),
3618 sym::usize => Self::Uint(UintTy::Usize),
3619 sym::f16 => Self::Float(FloatTy::F16),
3620 sym::f32 => Self::Float(FloatTy::F32),
3621 sym::f64 => Self::Float(FloatTy::F64),
3622 sym::f128 => Self::Float(FloatTy::F128),
3623 sym::bool => Self::Bool,
3624 sym::char => Self::Char,
3625 sym::str => Self::Str,
3626 _ => return None,
3627 };
3628 Some(ty)
3629 }
3630}
3631
3632#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnPtrTy<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "FnPtrTy",
"safety", &self.safety, "abi", &self.abi, "generic_params",
&self.generic_params, "decl", &self.decl, "param_idents",
&&self.param_idents)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnPtrTy<'hir> {
#[inline]
fn clone(&self) -> FnPtrTy<'hir> {
let _: ::core::clone::AssertParamIsClone<Safety>;
let _: ::core::clone::AssertParamIsClone<ExternAbi>;
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir FnDecl<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Option<Ident>]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnPtrTy<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnPtrTy<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FnPtrTy {
safety: ref __binding_0,
abi: ref __binding_1,
generic_params: ref __binding_2,
decl: ref __binding_3,
param_idents: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3633pub struct FnPtrTy<'hir> {
3634 pub safety: Safety,
3635 pub abi: ExternAbi,
3636 pub generic_params: &'hir [GenericParam<'hir>],
3637 pub decl: &'hir FnDecl<'hir>,
3638 pub param_idents: &'hir [Option<Ident>],
3641}
3642
3643#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for UnsafeBinderTy<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"UnsafeBinderTy", "generic_params", &self.generic_params,
"inner_ty", &&self.inner_ty)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for UnsafeBinderTy<'hir> {
#[inline]
fn clone(&self) -> UnsafeBinderTy<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for UnsafeBinderTy<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
UnsafeBinderTy<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
UnsafeBinderTy {
generic_params: ref __binding_0, inner_ty: ref __binding_1 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3644pub struct UnsafeBinderTy<'hir> {
3645 pub generic_params: &'hir [GenericParam<'hir>],
3646 pub inner_ty: &'hir Ty<'hir>,
3647}
3648
3649#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for OpaqueTy<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "OpaqueTy",
"hir_id", &self.hir_id, "def_id", &self.def_id, "bounds",
&self.bounds, "origin", &self.origin, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for OpaqueTy<'hir> {
#[inline]
fn clone(&self) -> OpaqueTy<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
let _: ::core::clone::AssertParamIsClone<OpaqueTyOrigin<LocalDefId>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for OpaqueTy<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
OpaqueTy<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
OpaqueTy {
hir_id: ref __binding_0,
def_id: ref __binding_1,
bounds: ref __binding_2,
origin: ref __binding_3,
span: ref __binding_4 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3650pub struct OpaqueTy<'hir> {
3651 #[stable_hasher(ignore)]
3652 pub hir_id: HirId,
3653 pub def_id: LocalDefId,
3654 pub bounds: GenericBounds<'hir>,
3655 pub origin: OpaqueTyOrigin<LocalDefId>,
3656 pub span: Span,
3657}
3658
3659#[derive(#[automatically_derived]
impl<T: ::core::fmt::Debug, U: ::core::fmt::Debug> ::core::fmt::Debug for
PreciseCapturingArgKind<T, U> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
PreciseCapturingArgKind::Lifetime(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Lifetime", &__self_0),
PreciseCapturingArgKind::Param(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Param",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<T: ::core::clone::Clone, U: ::core::clone::Clone> ::core::clone::Clone
for PreciseCapturingArgKind<T, U> {
#[inline]
fn clone(&self) -> PreciseCapturingArgKind<T, U> {
match self {
PreciseCapturingArgKind::Lifetime(__self_0) =>
PreciseCapturingArgKind::Lifetime(::core::clone::Clone::clone(__self_0)),
PreciseCapturingArgKind::Param(__self_0) =>
PreciseCapturingArgKind::Param(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]
impl<T: ::core::marker::Copy, U: ::core::marker::Copy> ::core::marker::Copy
for PreciseCapturingArgKind<T, U> {
}Copy, const _: () =
{
impl<T, U, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PreciseCapturingArgKind<T, U> where
__CTX: crate::HashStableContext,
T: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
U: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
PreciseCapturingArgKind::Lifetime(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
PreciseCapturingArgKind::Param(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
impl<T, U, __E: ::rustc_span::SpanEncoder>
::rustc_serialize::Encodable<__E> for
PreciseCapturingArgKind<T, U> where
T: ::rustc_serialize::Encodable<__E>,
U: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
PreciseCapturingArgKind::Lifetime(ref __binding_0) => {
0usize
}
PreciseCapturingArgKind::Param(ref __binding_0) => {
1usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
PreciseCapturingArgKind::Lifetime(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
PreciseCapturingArgKind::Param(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<T, U, __D: ::rustc_span::SpanDecoder>
::rustc_serialize::Decodable<__D> for
PreciseCapturingArgKind<T, U> where
T: ::rustc_serialize::Decodable<__D>,
U: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
PreciseCapturingArgKind::Lifetime(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
PreciseCapturingArgKind::Param(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `PreciseCapturingArgKind`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
3660pub enum PreciseCapturingArgKind<T, U> {
3661 Lifetime(T),
3662 Param(U),
3664}
3665
3666pub type PreciseCapturingArg<'hir> =
3667 PreciseCapturingArgKind<&'hir Lifetime, PreciseCapturingNonLifetimeArg>;
3668
3669impl PreciseCapturingArg<'_> {
3670 pub fn hir_id(self) -> HirId {
3671 match self {
3672 PreciseCapturingArg::Lifetime(lt) => lt.hir_id,
3673 PreciseCapturingArg::Param(param) => param.hir_id,
3674 }
3675 }
3676
3677 pub fn name(self) -> Symbol {
3678 match self {
3679 PreciseCapturingArg::Lifetime(lt) => lt.ident.name,
3680 PreciseCapturingArg::Param(param) => param.ident.name,
3681 }
3682 }
3683}
3684
3685#[derive(#[automatically_derived]
impl ::core::fmt::Debug for PreciseCapturingNonLifetimeArg {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"PreciseCapturingNonLifetimeArg", "hir_id", &self.hir_id, "ident",
&self.ident, "res", &&self.res)
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for PreciseCapturingNonLifetimeArg {
#[inline]
fn clone(&self) -> PreciseCapturingNonLifetimeArg {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<Res>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for PreciseCapturingNonLifetimeArg { }Copy, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for PreciseCapturingNonLifetimeArg where
__CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
PreciseCapturingNonLifetimeArg {
hir_id: ref __binding_0,
ident: ref __binding_1,
res: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3690pub struct PreciseCapturingNonLifetimeArg {
3691 #[stable_hasher(ignore)]
3692 pub hir_id: HirId,
3693 pub ident: Ident,
3694 pub res: Res,
3695}
3696
3697#[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_receiver_is_total_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)]
3698#[derive(const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for RpitContext where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
RpitContext::Trait => {}
RpitContext::TraitImpl => {}
}
}
}
};HashStable_Generic, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for RpitContext {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
RpitContext::Trait => { 0usize }
RpitContext::TraitImpl => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
RpitContext::Trait => {}
RpitContext::TraitImpl => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for RpitContext {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { RpitContext::Trait }
1usize => { RpitContext::TraitImpl }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `RpitContext`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
3699pub enum RpitContext {
3700 Trait,
3701 TraitImpl,
3702}
3703
3704#[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_receiver_is_total_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)]
3706#[derive(const _: () =
{
impl<D, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
OpaqueTyOrigin<D> where __CTX: crate::HashStableContext,
D: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
OpaqueTyOrigin::FnReturn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
OpaqueTyOrigin::AsyncFn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
OpaqueTyOrigin::TyAlias {
parent: ref __binding_0, in_assoc_ty: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
impl<D, __E: ::rustc_span::SpanEncoder>
::rustc_serialize::Encodable<__E> for OpaqueTyOrigin<D> where
D: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
OpaqueTyOrigin::FnReturn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
0usize
}
OpaqueTyOrigin::AsyncFn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
1usize
}
OpaqueTyOrigin::TyAlias {
parent: ref __binding_0, in_assoc_ty: ref __binding_1 } => {
2usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
OpaqueTyOrigin::FnReturn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
OpaqueTyOrigin::AsyncFn {
parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
OpaqueTyOrigin::TyAlias {
parent: ref __binding_0, in_assoc_ty: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<D, __D: ::rustc_span::SpanDecoder>
::rustc_serialize::Decodable<__D> for OpaqueTyOrigin<D> where
D: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
OpaqueTyOrigin::FnReturn {
parent: ::rustc_serialize::Decodable::decode(__decoder),
in_trait_or_impl: ::rustc_serialize::Decodable::decode(__decoder),
}
}
1usize => {
OpaqueTyOrigin::AsyncFn {
parent: ::rustc_serialize::Decodable::decode(__decoder),
in_trait_or_impl: ::rustc_serialize::Decodable::decode(__decoder),
}
}
2usize => {
OpaqueTyOrigin::TyAlias {
parent: ::rustc_serialize::Decodable::decode(__decoder),
in_assoc_ty: ::rustc_serialize::Decodable::decode(__decoder),
}
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `OpaqueTyOrigin`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
3707pub enum OpaqueTyOrigin<D> {
3708 FnReturn {
3710 parent: D,
3712 in_trait_or_impl: Option<RpitContext>,
3714 },
3715 AsyncFn {
3717 parent: D,
3719 in_trait_or_impl: Option<RpitContext>,
3721 },
3722 TyAlias {
3724 parent: D,
3726 in_assoc_ty: bool,
3728 },
3729}
3730
3731#[derive(#[automatically_derived]
impl ::core::fmt::Debug for InferDelegationKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
InferDelegationKind::Input(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Input",
&__self_0),
InferDelegationKind::Output =>
::core::fmt::Formatter::write_str(f, "Output"),
}
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for InferDelegationKind {
#[inline]
fn clone(&self) -> InferDelegationKind {
let _: ::core::clone::AssertParamIsClone<usize>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InferDelegationKind { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for InferDelegationKind {
#[inline]
fn eq(&self, other: &InferDelegationKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(InferDelegationKind::Input(__self_0),
InferDelegationKind::Input(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for InferDelegationKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<usize>;
}
}Eq, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for InferDelegationKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
InferDelegationKind::Input(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
InferDelegationKind::Output => {}
}
}
}
};HashStable_Generic)]
3732pub enum InferDelegationKind {
3733 Input(usize),
3734 Output,
3735}
3736
3737#[repr(u8, C)]
3743#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
TyKind<'hir, Unambig> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
TyKind::InferDelegation(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"InferDelegation", __self_0, &__self_1),
TyKind::Slice(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Slice",
&__self_0),
TyKind::Array(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Array",
__self_0, &__self_1),
TyKind::Ptr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ptr",
&__self_0),
TyKind::Ref(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Ref",
__self_0, &__self_1),
TyKind::FnPtr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "FnPtr",
&__self_0),
TyKind::UnsafeBinder(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"UnsafeBinder", &__self_0),
TyKind::Never => ::core::fmt::Formatter::write_str(f, "Never"),
TyKind::Tup(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tup",
&__self_0),
TyKind::Path(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
&__self_0),
TyKind::OpaqueDef(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"OpaqueDef", &__self_0),
TyKind::TraitAscription(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TraitAscription", &__self_0),
TyKind::TraitObject(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"TraitObject", __self_0, &__self_1),
TyKind::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
TyKind::Pat(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Pat",
__self_0, &__self_1),
TyKind::Infer(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
TyKind<'hir, Unambig> {
#[inline]
fn clone(&self) -> TyKind<'hir, Unambig> {
match self {
TyKind::InferDelegation(__self_0, __self_1) =>
TyKind::InferDelegation(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::Slice(__self_0) =>
TyKind::Slice(::core::clone::Clone::clone(__self_0)),
TyKind::Array(__self_0, __self_1) =>
TyKind::Array(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::Ptr(__self_0) =>
TyKind::Ptr(::core::clone::Clone::clone(__self_0)),
TyKind::Ref(__self_0, __self_1) =>
TyKind::Ref(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::FnPtr(__self_0) =>
TyKind::FnPtr(::core::clone::Clone::clone(__self_0)),
TyKind::UnsafeBinder(__self_0) =>
TyKind::UnsafeBinder(::core::clone::Clone::clone(__self_0)),
TyKind::Never => TyKind::Never,
TyKind::Tup(__self_0) =>
TyKind::Tup(::core::clone::Clone::clone(__self_0)),
TyKind::Path(__self_0) =>
TyKind::Path(::core::clone::Clone::clone(__self_0)),
TyKind::OpaqueDef(__self_0) =>
TyKind::OpaqueDef(::core::clone::Clone::clone(__self_0)),
TyKind::TraitAscription(__self_0) =>
TyKind::TraitAscription(::core::clone::Clone::clone(__self_0)),
TyKind::TraitObject(__self_0, __self_1) =>
TyKind::TraitObject(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::Err(__self_0) =>
TyKind::Err(::core::clone::Clone::clone(__self_0)),
TyKind::Pat(__self_0, __self_1) =>
TyKind::Pat(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
TyKind::Infer(__self_0) =>
TyKind::Infer(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
TyKind<'hir, Unambig> {
}Copy, const _: () =
{
impl<'hir, Unambig, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TyKind<'hir, Unambig> where __CTX: crate::HashStableContext,
Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
TyKind::InferDelegation(ref __binding_0, ref __binding_1) =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Slice(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Array(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Ptr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Ref(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::FnPtr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::UnsafeBinder(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Never => {}
TyKind::Tup(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Path(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::OpaqueDef(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::TraitAscription(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::TraitObject(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Pat(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Infer(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3744pub enum TyKind<'hir, Unambig = ()> {
3745 InferDelegation(DefId, InferDelegationKind),
3747 Slice(&'hir Ty<'hir>),
3749 Array(&'hir Ty<'hir>, &'hir ConstArg<'hir>),
3751 Ptr(MutTy<'hir>),
3753 Ref(&'hir Lifetime, MutTy<'hir>),
3755 FnPtr(&'hir FnPtrTy<'hir>),
3757 UnsafeBinder(&'hir UnsafeBinderTy<'hir>),
3759 Never,
3761 Tup(&'hir [Ty<'hir>]),
3763 Path(QPath<'hir>),
3768 OpaqueDef(&'hir OpaqueTy<'hir>),
3770 TraitAscription(GenericBounds<'hir>),
3772 TraitObject(&'hir [PolyTraitRef<'hir>], TaggedRef<'hir, Lifetime, TraitObjectSyntax>),
3778 Err(rustc_span::ErrorGuaranteed),
3780 Pat(&'hir Ty<'hir>, &'hir TyPat<'hir>),
3782 Infer(Unambig),
3788}
3789
3790#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InlineAsmOperand<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
InlineAsmOperand::In { reg: __self_0, expr: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "In",
"reg", __self_0, "expr", &__self_1),
InlineAsmOperand::Out {
reg: __self_0, late: __self_1, expr: __self_2 } =>
::core::fmt::Formatter::debug_struct_field3_finish(f, "Out",
"reg", __self_0, "late", __self_1, "expr", &__self_2),
InlineAsmOperand::InOut {
reg: __self_0, late: __self_1, expr: __self_2 } =>
::core::fmt::Formatter::debug_struct_field3_finish(f, "InOut",
"reg", __self_0, "late", __self_1, "expr", &__self_2),
InlineAsmOperand::SplitInOut {
reg: __self_0,
late: __self_1,
in_expr: __self_2,
out_expr: __self_3 } =>
::core::fmt::Formatter::debug_struct_field4_finish(f,
"SplitInOut", "reg", __self_0, "late", __self_1, "in_expr",
__self_2, "out_expr", &__self_3),
InlineAsmOperand::Const { anon_const: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Const",
"anon_const", &__self_0),
InlineAsmOperand::SymFn { expr: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "SymFn",
"expr", &__self_0),
InlineAsmOperand::SymStatic { path: __self_0, def_id: __self_1 }
=>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"SymStatic", "path", __self_0, "def_id", &__self_1),
InlineAsmOperand::Label { block: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Label",
"block", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InlineAsmOperand<'hir> {
#[inline]
fn clone(&self) -> InlineAsmOperand<'hir> {
let _: ::core::clone::AssertParamIsClone<InlineAsmRegOrRegClass>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
let _: ::core::clone::AssertParamIsClone<ConstBlock>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
let _: ::core::clone::AssertParamIsClone<DefId>;
let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InlineAsmOperand<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
InlineAsmOperand<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
InlineAsmOperand::In {
reg: ref __binding_0, expr: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::Out {
reg: ref __binding_0,
late: ref __binding_1,
expr: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::InOut {
reg: ref __binding_0,
late: ref __binding_1,
expr: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::SplitInOut {
reg: ref __binding_0,
late: ref __binding_1,
in_expr: ref __binding_2,
out_expr: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::Const { anon_const: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::SymFn { expr: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::SymStatic {
path: ref __binding_0, def_id: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
InlineAsmOperand::Label { block: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3791pub enum InlineAsmOperand<'hir> {
3792 In {
3793 reg: InlineAsmRegOrRegClass,
3794 expr: &'hir Expr<'hir>,
3795 },
3796 Out {
3797 reg: InlineAsmRegOrRegClass,
3798 late: bool,
3799 expr: Option<&'hir Expr<'hir>>,
3800 },
3801 InOut {
3802 reg: InlineAsmRegOrRegClass,
3803 late: bool,
3804 expr: &'hir Expr<'hir>,
3805 },
3806 SplitInOut {
3807 reg: InlineAsmRegOrRegClass,
3808 late: bool,
3809 in_expr: &'hir Expr<'hir>,
3810 out_expr: Option<&'hir Expr<'hir>>,
3811 },
3812 Const {
3813 anon_const: ConstBlock,
3814 },
3815 SymFn {
3816 expr: &'hir Expr<'hir>,
3817 },
3818 SymStatic {
3819 path: QPath<'hir>,
3820 def_id: DefId,
3821 },
3822 Label {
3823 block: &'hir Block<'hir>,
3824 },
3825}
3826
3827impl<'hir> InlineAsmOperand<'hir> {
3828 pub fn reg(&self) -> Option<InlineAsmRegOrRegClass> {
3829 match *self {
3830 Self::In { reg, .. }
3831 | Self::Out { reg, .. }
3832 | Self::InOut { reg, .. }
3833 | Self::SplitInOut { reg, .. } => Some(reg),
3834 Self::Const { .. }
3835 | Self::SymFn { .. }
3836 | Self::SymStatic { .. }
3837 | Self::Label { .. } => None,
3838 }
3839 }
3840
3841 pub fn is_clobber(&self) -> bool {
3842 #[allow(non_exhaustive_omitted_patterns)] match self {
InlineAsmOperand::Out {
reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None } => true,
_ => false,
}matches!(
3843 self,
3844 InlineAsmOperand::Out { reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None }
3845 )
3846 }
3847}
3848
3849#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InlineAsm<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["asm_macro", "template", "template_strs", "operands", "options",
"line_spans"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.asm_macro, &self.template, &self.template_strs,
&self.operands, &self.options, &&self.line_spans];
::core::fmt::Formatter::debug_struct_fields_finish(f, "InlineAsm",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InlineAsm<'hir> {
#[inline]
fn clone(&self) -> InlineAsm<'hir> {
let _: ::core::clone::AssertParamIsClone<ast::AsmMacro>;
let _:
::core::clone::AssertParamIsClone<&'hir [InlineAsmTemplatePiece]>;
let _:
::core::clone::AssertParamIsClone<&'hir [(Symbol,
Option<Symbol>, Span)]>;
let _:
::core::clone::AssertParamIsClone<&'hir [(InlineAsmOperand<'hir>,
Span)]>;
let _: ::core::clone::AssertParamIsClone<InlineAsmOptions>;
let _: ::core::clone::AssertParamIsClone<&'hir [Span]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InlineAsm<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
InlineAsm<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
InlineAsm {
asm_macro: ref __binding_0,
template: ref __binding_1,
template_strs: ref __binding_2,
operands: ref __binding_3,
options: ref __binding_4,
line_spans: ref __binding_5 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3850pub struct InlineAsm<'hir> {
3851 pub asm_macro: ast::AsmMacro,
3852 pub template: &'hir [InlineAsmTemplatePiece],
3853 pub template_strs: &'hir [(Symbol, Option<Symbol>, Span)],
3854 pub operands: &'hir [(InlineAsmOperand<'hir>, Span)],
3855 pub options: InlineAsmOptions,
3856 pub line_spans: &'hir [Span],
3857}
3858
3859impl InlineAsm<'_> {
3860 pub fn contains_label(&self) -> bool {
3861 self.operands.iter().any(|x| #[allow(non_exhaustive_omitted_patterns)] match x.0 {
InlineAsmOperand::Label { .. } => true,
_ => false,
}matches!(x.0, InlineAsmOperand::Label { .. }))
3862 }
3863}
3864
3865#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Param<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "Param",
"hir_id", &self.hir_id, "pat", &self.pat, "ty_span",
&self.ty_span, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Param<'hir> {
#[inline]
fn clone(&self) -> Param<'hir> {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Param<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Param<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Param {
hir_id: ref __binding_0,
pat: ref __binding_1,
ty_span: ref __binding_2,
span: ref __binding_3 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3867pub struct Param<'hir> {
3868 #[stable_hasher(ignore)]
3869 pub hir_id: HirId,
3870 pub pat: &'hir Pat<'hir>,
3871 pub ty_span: Span,
3872 pub span: Span,
3873}
3874
3875#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnDecl<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "FnDecl",
"inputs", &self.inputs, "output", &self.output, "c_variadic",
&self.c_variadic, "implicit_self", &self.implicit_self,
"lifetime_elision_allowed", &&self.lifetime_elision_allowed)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnDecl<'hir> {
#[inline]
fn clone(&self) -> FnDecl<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [Ty<'hir>]>;
let _: ::core::clone::AssertParamIsClone<FnRetTy<'hir>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<ImplicitSelfKind>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnDecl<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnDecl<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FnDecl {
inputs: ref __binding_0,
output: ref __binding_1,
c_variadic: ref __binding_2,
implicit_self: ref __binding_3,
lifetime_elision_allowed: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3877pub struct FnDecl<'hir> {
3878 pub inputs: &'hir [Ty<'hir>],
3882 pub output: FnRetTy<'hir>,
3883 pub c_variadic: bool,
3884 pub implicit_self: ImplicitSelfKind,
3886 pub lifetime_elision_allowed: bool,
3888}
3889
3890impl<'hir> FnDecl<'hir> {
3891 pub fn opt_delegation_sig_id(&self) -> Option<DefId> {
3892 if let FnRetTy::Return(ty) = self.output
3893 && let TyKind::InferDelegation(sig_id, _) = ty.kind
3894 {
3895 return Some(sig_id);
3896 }
3897 None
3898 }
3899}
3900
3901#[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_receiver_is_total_eq(&self) {}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ImplicitSelfKind {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
ImplicitSelfKind::Imm => { 0usize }
ImplicitSelfKind::Mut => { 1usize }
ImplicitSelfKind::RefImm => { 2usize }
ImplicitSelfKind::RefMut => { 3usize }
ImplicitSelfKind::None => { 4usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
ImplicitSelfKind::Imm => {}
ImplicitSelfKind::Mut => {}
ImplicitSelfKind::RefImm => {}
ImplicitSelfKind::RefMut => {}
ImplicitSelfKind::None => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ImplicitSelfKind {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { ImplicitSelfKind::Imm }
1usize => { ImplicitSelfKind::Mut }
2usize => { ImplicitSelfKind::RefImm }
3usize => { ImplicitSelfKind::RefMut }
4usize => { ImplicitSelfKind::None }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ImplicitSelfKind`, expected 0..5, actual {0}",
n));
}
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ImplicitSelfKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
ImplicitSelfKind::Imm => "Imm",
ImplicitSelfKind::Mut => "Mut",
ImplicitSelfKind::RefImm => "RefImm",
ImplicitSelfKind::RefMut => "RefMut",
ImplicitSelfKind::None => "None",
})
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ImplicitSelfKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ImplicitSelfKind::Imm => {}
ImplicitSelfKind::Mut => {}
ImplicitSelfKind::RefImm => {}
ImplicitSelfKind::RefMut => {}
ImplicitSelfKind::None => {}
}
}
}
};HashStable_Generic)]
3903pub enum ImplicitSelfKind {
3904 Imm,
3906 Mut,
3908 RefImm,
3910 RefMut,
3912 None,
3915}
3916
3917impl ImplicitSelfKind {
3918 pub fn has_implicit_self(&self) -> bool {
3920 !#[allow(non_exhaustive_omitted_patterns)] match *self {
ImplicitSelfKind::None => true,
_ => false,
}matches!(*self, ImplicitSelfKind::None)
3921 }
3922}
3923
3924#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Span>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for IsAsync {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
IsAsync::Async(ref __binding_0) => { 0usize }
IsAsync::NotAsync => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
IsAsync::Async(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
IsAsync::NotAsync => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for IsAsync {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
IsAsync::Async(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => { IsAsync::NotAsync }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `IsAsync`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for IsAsync {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
IsAsync::Async(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Async",
&__self_0),
IsAsync::NotAsync =>
::core::fmt::Formatter::write_str(f, "NotAsync"),
}
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for IsAsync where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
IsAsync::Async(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
IsAsync::NotAsync => {}
}
}
}
};HashStable_Generic)]
3925pub enum IsAsync {
3926 Async(Span),
3927 NotAsync,
3928}
3929
3930impl IsAsync {
3931 pub fn is_async(self) -> bool {
3932 #[allow(non_exhaustive_omitted_patterns)] match self {
IsAsync::Async(_) => true,
_ => false,
}matches!(self, IsAsync::Async(_))
3933 }
3934}
3935
3936#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for Defaultness {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Defaultness::Default { has_value: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Default", "has_value", &__self_0),
Defaultness::Final =>
::core::fmt::Formatter::write_str(f, "Final"),
}
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Defaultness {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Defaultness::Default { has_value: ref __binding_0 } => {
0usize
}
Defaultness::Final => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Defaultness::Default { has_value: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
Defaultness::Final => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Defaultness {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
Defaultness::Default {
has_value: ::rustc_serialize::Decodable::decode(__decoder),
}
}
1usize => { Defaultness::Final }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Defaultness`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Defaultness where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Defaultness::Default { has_value: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Defaultness::Final => {}
}
}
}
};HashStable_Generic)]
3937#[derive(#[automatically_derived]
impl ::core::default::Default for Defaultness {
#[inline]
fn default() -> Defaultness { Self::Final }
}Default)]
3938pub enum Defaultness {
3939 Default {
3940 has_value: bool,
3941 },
3942 #[default]
3943 Final,
3944}
3945
3946impl Defaultness {
3947 pub fn has_value(&self) -> bool {
3948 match *self {
3949 Defaultness::Default { has_value } => has_value,
3950 Defaultness::Final => true,
3951 }
3952 }
3953
3954 pub fn is_final(&self) -> bool {
3955 *self == Defaultness::Final
3956 }
3957
3958 pub fn is_default(&self) -> bool {
3959 #[allow(non_exhaustive_omitted_patterns)] match *self {
Defaultness::Default { .. } => true,
_ => false,
}matches!(*self, Defaultness::Default { .. })
3960 }
3961}
3962
3963#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnRetTy<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
FnRetTy::DefaultReturn(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"DefaultReturn", &__self_0),
FnRetTy::Return(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Return",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnRetTy<'hir> {
#[inline]
fn clone(&self) -> FnRetTy<'hir> {
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnRetTy<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnRetTy<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
FnRetTy::DefaultReturn(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
FnRetTy::Return(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3964pub enum FnRetTy<'hir> {
3965 DefaultReturn(Span),
3971 Return(&'hir Ty<'hir>),
3973}
3974
3975impl<'hir> FnRetTy<'hir> {
3976 #[inline]
3977 pub fn span(&self) -> Span {
3978 match *self {
3979 Self::DefaultReturn(span) => span,
3980 Self::Return(ref ty) => ty.span,
3981 }
3982 }
3983
3984 pub fn is_suggestable_infer_ty(&self) -> Option<&'hir Ty<'hir>> {
3985 if let Self::Return(ty) = self
3986 && ty.is_suggestable_infer_ty()
3987 {
3988 return Some(*ty);
3989 }
3990 None
3991 }
3992}
3993
3994#[derive(#[automatically_derived]
impl ::core::marker::Copy for ClosureBinder { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ClosureBinder {
#[inline]
fn clone(&self) -> ClosureBinder {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ClosureBinder {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ClosureBinder::Default =>
::core::fmt::Formatter::write_str(f, "Default"),
ClosureBinder::For { span: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "For",
"span", &__self_0),
}
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ClosureBinder where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ClosureBinder::Default => {}
ClosureBinder::For { span: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
3996pub enum ClosureBinder {
3997 Default,
3999 For { span: Span },
4003}
4004
4005#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Mod<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Mod", "spans",
&self.spans, "item_ids", &&self.item_ids)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Mod<'hir> {
#[inline]
fn clone(&self) -> Mod<'hir> {
let _: ::core::clone::AssertParamIsClone<ModSpans>;
let _: ::core::clone::AssertParamIsClone<&'hir [ItemId]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Mod<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Mod<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Mod { spans: ref __binding_0, item_ids: ref __binding_1 } =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4006pub struct Mod<'hir> {
4007 pub spans: ModSpans,
4008 pub item_ids: &'hir [ItemId],
4009}
4010
4011#[derive(#[automatically_derived]
impl ::core::marker::Copy for ModSpans { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ModSpans {
#[inline]
fn clone(&self) -> ModSpans {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ModSpans {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "ModSpans",
"inner_span", &self.inner_span, "inject_use_span",
&&self.inject_use_span)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ModSpans where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ModSpans {
inner_span: ref __binding_0,
inject_use_span: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4012pub struct ModSpans {
4013 pub inner_span: Span,
4017 pub inject_use_span: Span,
4018}
4019
4020#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for EnumDef<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "EnumDef",
"variants", &&self.variants)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for EnumDef<'hir> {
#[inline]
fn clone(&self) -> EnumDef<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [Variant<'hir>]>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for EnumDef<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
EnumDef<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
EnumDef { variants: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4021pub struct EnumDef<'hir> {
4022 pub variants: &'hir [Variant<'hir>],
4023}
4024
4025#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Variant<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["ident", "hir_id", "def_id", "data", "disr_expr", "span"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.hir_id, &self.def_id, &self.data,
&self.disr_expr, &&self.span];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Variant",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Variant<'hir> {
#[inline]
fn clone(&self) -> Variant<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<VariantData<'hir>>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir AnonConst>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Variant<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Variant<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Variant {
ident: ref __binding_0,
hir_id: ref __binding_1,
def_id: ref __binding_2,
data: ref __binding_3,
disr_expr: ref __binding_4,
span: ref __binding_5 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{}
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4026pub struct Variant<'hir> {
4027 pub ident: Ident,
4029 #[stable_hasher(ignore)]
4031 pub hir_id: HirId,
4032 pub def_id: LocalDefId,
4033 pub data: VariantData<'hir>,
4035 pub disr_expr: Option<&'hir AnonConst>,
4037 pub span: Span,
4039}
4040
4041#[derive(#[automatically_derived]
impl ::core::marker::Copy for UseKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for UseKind {
#[inline]
fn clone(&self) -> UseKind {
let _: ::core::clone::AssertParamIsClone<Ident>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for UseKind {
#[inline]
fn eq(&self, other: &UseKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(UseKind::Single(__self_0), UseKind::Single(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for UseKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
UseKind::Single(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Single",
&__self_0),
UseKind::Glob => ::core::fmt::Formatter::write_str(f, "Glob"),
UseKind::ListStem =>
::core::fmt::Formatter::write_str(f, "ListStem"),
}
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for UseKind where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
UseKind::Single(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
UseKind::Glob => {}
UseKind::ListStem => {}
}
}
}
};HashStable_Generic)]
4042pub enum UseKind {
4043 Single(Ident),
4050
4051 Glob,
4053
4054 ListStem,
4058}
4059
4060#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitRef<'hir> {
#[inline]
fn clone(&self) -> TraitRef<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Path<'hir>>;
let _: ::core::clone::AssertParamIsClone<HirId>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitRef<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "TraitRef",
"path", &self.path, "hir_ref_id", &&self.hir_ref_id)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitRef<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitRef<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitRef {
path: ref __binding_0, hir_ref_id: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{}
}
}
}
}
};HashStable_Generic)]
4067pub struct TraitRef<'hir> {
4068 pub path: &'hir Path<'hir>,
4069 #[stable_hasher(ignore)]
4071 pub hir_ref_id: HirId,
4072}
4073
4074impl TraitRef<'_> {
4075 pub fn trait_def_id(&self) -> Option<DefId> {
4077 match self.path.res {
4078 Res::Def(DefKind::Trait | DefKind::TraitAlias, did) => Some(did),
4079 Res::Err => None,
4080 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"),
4081 }
4082 }
4083}
4084
4085#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for PolyTraitRef<'hir> {
#[inline]
fn clone(&self) -> PolyTraitRef<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _: ::core::clone::AssertParamIsClone<TraitBoundModifiers>;
let _: ::core::clone::AssertParamIsClone<TraitRef<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for PolyTraitRef<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "PolyTraitRef",
"bound_generic_params", &self.bound_generic_params, "modifiers",
&self.modifiers, "trait_ref", &self.trait_ref, "span",
&&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PolyTraitRef<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PolyTraitRef<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
PolyTraitRef {
bound_generic_params: ref __binding_0,
modifiers: ref __binding_1,
trait_ref: ref __binding_2,
span: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4086pub struct PolyTraitRef<'hir> {
4087 pub bound_generic_params: &'hir [GenericParam<'hir>],
4089
4090 pub modifiers: TraitBoundModifiers,
4094
4095 pub trait_ref: TraitRef<'hir>,
4097
4098 pub span: Span,
4099}
4100
4101#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FieldDef<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["span", "vis_span", "ident", "hir_id", "def_id", "ty", "safety",
"default"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.span, &self.vis_span, &self.ident, &self.hir_id,
&self.def_id, &self.ty, &self.safety, &&self.default];
::core::fmt::Formatter::debug_struct_fields_finish(f, "FieldDef",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FieldDef<'hir> {
#[inline]
fn clone(&self) -> FieldDef<'hir> {
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<Safety>;
let _: ::core::clone::AssertParamIsClone<Option<&'hir AnonConst>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FieldDef<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FieldDef<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FieldDef {
span: ref __binding_0,
vis_span: ref __binding_1,
ident: ref __binding_2,
hir_id: ref __binding_3,
def_id: ref __binding_4,
ty: ref __binding_5,
safety: ref __binding_6,
default: ref __binding_7 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{}
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
{ __binding_7.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4102pub struct FieldDef<'hir> {
4103 pub span: Span,
4104 pub vis_span: Span,
4105 pub ident: Ident,
4106 #[stable_hasher(ignore)]
4107 pub hir_id: HirId,
4108 pub def_id: LocalDefId,
4109 pub ty: &'hir Ty<'hir>,
4110 pub safety: Safety,
4111 pub default: Option<&'hir AnonConst>,
4112}
4113
4114impl FieldDef<'_> {
4115 pub fn is_positional(&self) -> bool {
4117 self.ident.as_str().as_bytes()[0].is_ascii_digit()
4118 }
4119}
4120
4121#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for VariantData<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
VariantData::Struct { fields: __self_0, recovered: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"Struct", "fields", __self_0, "recovered", &__self_1),
VariantData::Tuple(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Tuple",
__self_0, __self_1, &__self_2),
VariantData::Unit(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Unit",
__self_0, &__self_1),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for VariantData<'hir> {
#[inline]
fn clone(&self) -> VariantData<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [FieldDef<'hir>]>;
let _: ::core::clone::AssertParamIsClone<ast::Recovered>;
let _: ::core::clone::AssertParamIsClone<&'hir [FieldDef<'hir>]>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<LocalDefId>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for VariantData<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
VariantData<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
VariantData::Struct {
fields: ref __binding_0, recovered: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
VariantData::Tuple(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{}
{ __binding_2.hash_stable(__hcx, __hasher); }
}
VariantData::Unit(ref __binding_0, ref __binding_1) => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4123pub enum VariantData<'hir> {
4124 Struct { fields: &'hir [FieldDef<'hir>], recovered: ast::Recovered },
4128 Tuple(&'hir [FieldDef<'hir>], #[stable_hasher(ignore)] HirId, LocalDefId),
4132 Unit(#[stable_hasher(ignore)] HirId, LocalDefId),
4136}
4137
4138impl<'hir> VariantData<'hir> {
4139 pub fn fields(&self) -> &'hir [FieldDef<'hir>] {
4141 match *self {
4142 VariantData::Struct { fields, .. } | VariantData::Tuple(fields, ..) => fields,
4143 _ => &[],
4144 }
4145 }
4146
4147 pub fn ctor(&self) -> Option<(CtorKind, HirId, LocalDefId)> {
4148 match *self {
4149 VariantData::Tuple(_, hir_id, def_id) => Some((CtorKind::Fn, hir_id, def_id)),
4150 VariantData::Unit(hir_id, def_id) => Some((CtorKind::Const, hir_id, def_id)),
4151 VariantData::Struct { .. } => None,
4152 }
4153 }
4154
4155 #[inline]
4156 pub fn ctor_kind(&self) -> Option<CtorKind> {
4157 self.ctor().map(|(kind, ..)| kind)
4158 }
4159
4160 #[inline]
4162 pub fn ctor_hir_id(&self) -> Option<HirId> {
4163 self.ctor().map(|(_, hir_id, _)| hir_id)
4164 }
4165
4166 #[inline]
4168 pub fn ctor_def_id(&self) -> Option<LocalDefId> {
4169 self.ctor().map(|(.., def_id)| def_id)
4170 }
4171}
4172
4173#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<OwnerId>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ItemId {
fn encode(&self, __encoder: &mut __E) {
match *self {
ItemId { owner_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ItemId {
fn decode(__decoder: &mut __D) -> Self {
ItemId {
owner_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ItemId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "ItemId",
"owner_id", &&self.owner_id)
}
}Debug, #[automatically_derived]
impl ::core::hash::Hash for ItemId {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.owner_id, state)
}
}Hash, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ItemId where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ItemId { owner_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4177pub struct ItemId {
4178 pub owner_id: OwnerId,
4179}
4180
4181impl ItemId {
4182 #[inline]
4183 pub fn hir_id(&self) -> HirId {
4184 HirId::make_owner(self.owner_id.def_id)
4186 }
4187}
4188
4189#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Item<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["owner_id", "kind", "span", "vis_span", "has_delayed_lints",
"eii"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.owner_id, &self.kind, &self.span, &self.vis_span,
&self.has_delayed_lints, &&self.eii];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Item", names,
values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Item<'hir> {
#[inline]
fn clone(&self) -> Item<'hir> {
let _: ::core::clone::AssertParamIsClone<OwnerId>;
let _: ::core::clone::AssertParamIsClone<ItemKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Item<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Item<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Item {
owner_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2,
vis_span: ref __binding_3,
has_delayed_lints: ref __binding_4,
eii: ref __binding_5 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4198pub struct Item<'hir> {
4199 pub owner_id: OwnerId,
4200 pub kind: ItemKind<'hir>,
4201 pub span: Span,
4202 pub vis_span: Span,
4203 pub has_delayed_lints: bool,
4204 pub eii: bool,
4207}
4208
4209impl<'hir> Item<'hir> {
4210 #[inline]
4211 pub fn hir_id(&self) -> HirId {
4212 HirId::make_owner(self.owner_id.def_id)
4214 }
4215
4216 pub fn item_id(&self) -> ItemId {
4217 ItemId { owner_id: self.owner_id }
4218 }
4219
4220 pub fn is_adt(&self) -> bool {
4223 #[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(..))
4224 }
4225
4226 pub fn is_struct_or_union(&self) -> bool {
4228 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ItemKind::Struct(..) | ItemKind::Union(..) => true,
_ => false,
}matches!(self.kind, ItemKind::Struct(..) | ItemKind::Union(..))
4229 }
4230
4231 self
let ItemKind::Impl(imp) =
&self.kind else { expect_failed("expect_impl", self) };
imp;expect_methods_self_kind! {
4232 expect_extern_crate, (Option<Symbol>, Ident),
4233 ItemKind::ExternCrate(s, ident), (*s, *ident);
4234
4235 expect_use, (&'hir UsePath<'hir>, UseKind), ItemKind::Use(p, uk), (p, *uk);
4236
4237 expect_static, (Mutability, Ident, &'hir Ty<'hir>, BodyId),
4238 ItemKind::Static(mutbl, ident, ty, body), (*mutbl, *ident, ty, *body);
4239
4240 expect_const, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4241 ItemKind::Const(ident, generics, ty, rhs), (*ident, generics, ty, *rhs);
4242
4243 expect_fn, (Ident, &FnSig<'hir>, &'hir Generics<'hir>, BodyId),
4244 ItemKind::Fn { ident, sig, generics, body, .. }, (*ident, sig, generics, *body);
4245
4246 expect_macro, (Ident, &ast::MacroDef, MacroKinds),
4247 ItemKind::Macro(ident, def, mk), (*ident, def, *mk);
4248
4249 expect_mod, (Ident, &'hir Mod<'hir>), ItemKind::Mod(ident, m), (*ident, m);
4250
4251 expect_foreign_mod, (ExternAbi, &'hir [ForeignItemId]),
4252 ItemKind::ForeignMod { abi, items }, (*abi, items);
4253
4254 expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm { asm, .. }, asm;
4255
4256 expect_ty_alias, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4257 ItemKind::TyAlias(ident, generics, ty), (*ident, generics, ty);
4258
4259 expect_enum, (Ident, &'hir Generics<'hir>, &EnumDef<'hir>),
4260 ItemKind::Enum(ident, generics, def), (*ident, generics, def);
4261
4262 expect_struct, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4263 ItemKind::Struct(ident, generics, data), (*ident, generics, data);
4264
4265 expect_union, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4266 ItemKind::Union(ident, generics, data), (*ident, generics, data);
4267
4268 expect_trait,
4269 (
4270 Constness,
4271 IsAuto,
4272 Safety,
4273 Ident,
4274 &'hir Generics<'hir>,
4275 GenericBounds<'hir>,
4276 &'hir [TraitItemId]
4277 ),
4278 ItemKind::Trait(constness, is_auto, safety, ident, generics, bounds, items),
4279 (*constness, *is_auto, *safety, *ident, generics, bounds, items);
4280
4281 expect_trait_alias, (Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4282 ItemKind::TraitAlias(constness, ident, generics, bounds), (*constness, *ident, generics, bounds);
4283
4284 expect_impl, &Impl<'hir>, ItemKind::Impl(imp), imp;
4285 }
4286}
4287
4288#[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_receiver_is_total_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)]
4289#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Safety {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Safety::Unsafe => { 0usize }
Safety::Safe => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self { Safety::Unsafe => {} Safety::Safe => {} }
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Safety {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { Safety::Unsafe }
1usize => { Safety::Safe }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Safety`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Safety where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self { Safety::Unsafe => {} Safety::Safe => {} }
}
}
};HashStable_Generic, #[automatically_derived]
impl ::core::default::Default for Safety {
#[inline]
fn default() -> Safety { Self::Unsafe }
}Default)]
4290pub enum Safety {
4291 #[default]
4296 Unsafe,
4297 Safe,
4298}
4299
4300impl Safety {
4301 pub fn prefix_str(self) -> &'static str {
4302 match self {
4303 Self::Unsafe => "unsafe ",
4304 Self::Safe => "",
4305 }
4306 }
4307
4308 #[inline]
4309 pub fn is_unsafe(self) -> bool {
4310 !self.is_safe()
4311 }
4312
4313 #[inline]
4314 pub fn is_safe(self) -> bool {
4315 match self {
4316 Self::Unsafe => false,
4317 Self::Safe => true,
4318 }
4319 }
4320}
4321
4322impl fmt::Display for Safety {
4323 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4324 f.write_str(match *self {
4325 Self::Unsafe => "unsafe",
4326 Self::Safe => "safe",
4327 })
4328 }
4329}
4330
4331#[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_receiver_is_total_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for Constness {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
Constness::Const => "Const",
Constness::NotConst => "NotConst",
})
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Constness {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Constness::Const => { 0usize }
Constness::NotConst => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Constness::Const => {}
Constness::NotConst => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Constness {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { Constness::Const }
1usize => { Constness::NotConst }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Constness`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Constness where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Constness::Const => {}
Constness::NotConst => {}
}
}
}
};HashStable_Generic)]
4332#[derive(#[automatically_derived]
impl ::core::default::Default for Constness {
#[inline]
fn default() -> Constness { Self::Const }
}Default)]
4333pub enum Constness {
4334 #[default]
4335 Const,
4336 NotConst,
4337}
4338
4339impl fmt::Display for Constness {
4340 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4341 f.write_str(match *self {
4342 Self::Const => "const",
4343 Self::NotConst => "non-const",
4344 })
4345 }
4346}
4347
4348#[derive(#[automatically_derived]
impl ::core::marker::Copy for HeaderSafety { }Copy, #[automatically_derived]
impl ::core::clone::Clone for HeaderSafety {
#[inline]
fn clone(&self) -> HeaderSafety {
let _: ::core::clone::AssertParamIsClone<Safety>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for HeaderSafety {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
HeaderSafety::SafeTargetFeatures =>
::core::fmt::Formatter::write_str(f, "SafeTargetFeatures"),
HeaderSafety::Normal(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Normal",
&__self_0),
}
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for HeaderSafety where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
HeaderSafety::SafeTargetFeatures => {}
HeaderSafety::Normal(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, #[automatically_derived]
impl ::core::cmp::PartialEq for HeaderSafety {
#[inline]
fn eq(&self, other: &HeaderSafety) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(HeaderSafety::Normal(__self_0),
HeaderSafety::Normal(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for HeaderSafety {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Safety>;
}
}Eq)]
4353pub enum HeaderSafety {
4354 SafeTargetFeatures,
4360 Normal(Safety),
4361}
4362
4363impl From<Safety> for HeaderSafety {
4364 fn from(v: Safety) -> Self {
4365 Self::Normal(v)
4366 }
4367}
4368
4369#[derive(#[automatically_derived]
impl ::core::marker::Copy for FnHeader { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FnHeader {
#[inline]
fn clone(&self) -> FnHeader {
let _: ::core::clone::AssertParamIsClone<HeaderSafety>;
let _: ::core::clone::AssertParamIsClone<Constness>;
let _: ::core::clone::AssertParamIsClone<IsAsync>;
let _: ::core::clone::AssertParamIsClone<ExternAbi>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for FnHeader {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "FnHeader",
"safety", &self.safety, "constness", &self.constness, "asyncness",
&self.asyncness, "abi", &&self.abi)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for FnHeader where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FnHeader {
safety: ref __binding_0,
constness: ref __binding_1,
asyncness: ref __binding_2,
abi: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4370pub struct FnHeader {
4371 pub safety: HeaderSafety,
4372 pub constness: Constness,
4373 pub asyncness: IsAsync,
4374 pub abi: ExternAbi,
4375}
4376
4377impl FnHeader {
4378 pub fn is_async(&self) -> bool {
4379 #[allow(non_exhaustive_omitted_patterns)] match self.asyncness {
IsAsync::Async(_) => true,
_ => false,
}matches!(self.asyncness, IsAsync::Async(_))
4380 }
4381
4382 pub fn is_const(&self) -> bool {
4383 #[allow(non_exhaustive_omitted_patterns)] match self.constness {
Constness::Const => true,
_ => false,
}matches!(self.constness, Constness::Const)
4384 }
4385
4386 pub fn is_unsafe(&self) -> bool {
4387 self.safety().is_unsafe()
4388 }
4389
4390 pub fn is_safe(&self) -> bool {
4391 self.safety().is_safe()
4392 }
4393
4394 pub fn safety(&self) -> Safety {
4395 match self.safety {
4396 HeaderSafety::SafeTargetFeatures => Safety::Unsafe,
4397 HeaderSafety::Normal(safety) => safety,
4398 }
4399 }
4400}
4401
4402#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ItemKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ItemKind::ExternCrate(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"ExternCrate", __self_0, &__self_1),
ItemKind::Use(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Use",
__self_0, &__self_1),
ItemKind::Static(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f, "Static",
__self_0, __self_1, __self_2, &__self_3),
ItemKind::Const(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f, "Const",
__self_0, __self_1, __self_2, &__self_3),
ItemKind::Fn {
sig: __self_0,
ident: __self_1,
generics: __self_2,
body: __self_3,
has_body: __self_4 } =>
::core::fmt::Formatter::debug_struct_field5_finish(f, "Fn",
"sig", __self_0, "ident", __self_1, "generics", __self_2,
"body", __self_3, "has_body", &__self_4),
ItemKind::Macro(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Macro",
__self_0, __self_1, &__self_2),
ItemKind::Mod(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f, "Mod",
__self_0, &__self_1),
ItemKind::ForeignMod { abi: __self_0, items: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"ForeignMod", "abi", __self_0, "items", &__self_1),
ItemKind::GlobalAsm { asm: __self_0, fake_body: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"GlobalAsm", "asm", __self_0, "fake_body", &__self_1),
ItemKind::TyAlias(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f,
"TyAlias", __self_0, __self_1, &__self_2),
ItemKind::Enum(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Enum",
__self_0, __self_1, &__self_2),
ItemKind::Struct(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Struct",
__self_0, __self_1, &__self_2),
ItemKind::Union(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Union",
__self_0, __self_1, &__self_2),
ItemKind::Trait(__self_0, __self_1, __self_2, __self_3, __self_4,
__self_5, __self_6) => {
let values: &[&dyn ::core::fmt::Debug] =
&[__self_0, __self_1, __self_2, __self_3, __self_4,
__self_5, &__self_6];
::core::fmt::Formatter::debug_tuple_fields_finish(f, "Trait",
values)
}
ItemKind::TraitAlias(__self_0, __self_1, __self_2, __self_3) =>
::core::fmt::Formatter::debug_tuple_field4_finish(f,
"TraitAlias", __self_0, __self_1, __self_2, &__self_3),
ItemKind::Impl(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Impl",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ItemKind<'hir> {
#[inline]
fn clone(&self) -> ItemKind<'hir> {
let _: ::core::clone::AssertParamIsClone<Option<Symbol>>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<&'hir UsePath<'hir>>;
let _: ::core::clone::AssertParamIsClone<UseKind>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<ConstItemRhs<'hir>>;
let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<&'hir ast::MacroDef>;
let _: ::core::clone::AssertParamIsClone<MacroKinds>;
let _: ::core::clone::AssertParamIsClone<&'hir Mod<'hir>>;
let _: ::core::clone::AssertParamIsClone<ExternAbi>;
let _: ::core::clone::AssertParamIsClone<&'hir [ForeignItemId]>;
let _: ::core::clone::AssertParamIsClone<&'hir InlineAsm<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<EnumDef<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<VariantData<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<VariantData<'hir>>;
let _: ::core::clone::AssertParamIsClone<Constness>;
let _: ::core::clone::AssertParamIsClone<IsAuto>;
let _: ::core::clone::AssertParamIsClone<Safety>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [TraitItemId]>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
let _: ::core::clone::AssertParamIsClone<Impl<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ItemKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ItemKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ItemKind::ExternCrate(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ItemKind::Use(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ItemKind::Static(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
ItemKind::Const(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
ItemKind::Fn {
sig: ref __binding_0,
ident: ref __binding_1,
generics: ref __binding_2,
body: ref __binding_3,
has_body: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
ItemKind::Macro(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ItemKind::Mod(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ItemKind::ForeignMod {
abi: ref __binding_0, items: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ItemKind::GlobalAsm {
asm: ref __binding_0, fake_body: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ItemKind::TyAlias(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ItemKind::Enum(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ItemKind::Struct(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ItemKind::Union(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ItemKind::Trait(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3, ref __binding_4,
ref __binding_5, ref __binding_6) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
}
ItemKind::TraitAlias(ref __binding_0, ref __binding_1,
ref __binding_2, ref __binding_3) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
ItemKind::Impl(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4403pub enum ItemKind<'hir> {
4404 ExternCrate(Option<Symbol>, Ident),
4408
4409 Use(&'hir UsePath<'hir>, UseKind),
4415
4416 Static(Mutability, Ident, &'hir Ty<'hir>, BodyId),
4418 Const(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4420 Fn {
4422 sig: FnSig<'hir>,
4423 ident: Ident,
4424 generics: &'hir Generics<'hir>,
4425 body: BodyId,
4426 has_body: bool,
4430 },
4431 Macro(Ident, &'hir ast::MacroDef, MacroKinds),
4433 Mod(Ident, &'hir Mod<'hir>),
4435 ForeignMod { abi: ExternAbi, items: &'hir [ForeignItemId] },
4437 GlobalAsm {
4439 asm: &'hir InlineAsm<'hir>,
4440 fake_body: BodyId,
4446 },
4447 TyAlias(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4449 Enum(Ident, &'hir Generics<'hir>, EnumDef<'hir>),
4451 Struct(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4453 Union(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4455 Trait(
4457 Constness,
4458 IsAuto,
4459 Safety,
4460 Ident,
4461 &'hir Generics<'hir>,
4462 GenericBounds<'hir>,
4463 &'hir [TraitItemId],
4464 ),
4465 TraitAlias(Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4467
4468 Impl(Impl<'hir>),
4470}
4471
4472#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Impl<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Impl",
"generics", &self.generics, "of_trait", &self.of_trait, "self_ty",
&self.self_ty, "items", &self.items, "constness",
&&self.constness)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Impl<'hir> {
#[inline]
fn clone(&self) -> Impl<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _:
::core::clone::AssertParamIsClone<Option<&'hir TraitImplHeader<'hir>>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [ImplItemId]>;
let _: ::core::clone::AssertParamIsClone<Constness>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Impl<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Impl<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Impl {
generics: ref __binding_0,
of_trait: ref __binding_1,
self_ty: ref __binding_2,
items: ref __binding_3,
constness: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4477pub struct Impl<'hir> {
4478 pub generics: &'hir Generics<'hir>,
4479 pub of_trait: Option<&'hir TraitImplHeader<'hir>>,
4480 pub self_ty: &'hir Ty<'hir>,
4481 pub items: &'hir [ImplItemId],
4482 pub constness: Constness,
4483}
4484
4485#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitImplHeader<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f,
"TraitImplHeader", "safety", &self.safety, "polarity",
&self.polarity, "defaultness", &self.defaultness,
"defaultness_span", &self.defaultness_span, "trait_ref",
&&self.trait_ref)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitImplHeader<'hir> {
#[inline]
fn clone(&self) -> TraitImplHeader<'hir> {
let _: ::core::clone::AssertParamIsClone<Safety>;
let _: ::core::clone::AssertParamIsClone<ImplPolarity>;
let _: ::core::clone::AssertParamIsClone<Defaultness>;
let _: ::core::clone::AssertParamIsClone<Option<Span>>;
let _: ::core::clone::AssertParamIsClone<TraitRef<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitImplHeader<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TraitImplHeader<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitImplHeader {
safety: ref __binding_0,
polarity: ref __binding_1,
defaultness: ref __binding_2,
defaultness_span: ref __binding_3,
trait_ref: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4486pub struct TraitImplHeader<'hir> {
4487 pub safety: Safety,
4488 pub polarity: ImplPolarity,
4489 pub defaultness: Defaultness,
4490 pub defaultness_span: Option<Span>,
4493 pub trait_ref: TraitRef<'hir>,
4494}
4495
4496impl ItemKind<'_> {
4497 pub fn ident(&self) -> Option<Ident> {
4498 match *self {
4499 ItemKind::ExternCrate(_, ident)
4500 | ItemKind::Use(_, UseKind::Single(ident))
4501 | ItemKind::Static(_, ident, ..)
4502 | ItemKind::Const(ident, ..)
4503 | ItemKind::Fn { ident, .. }
4504 | ItemKind::Macro(ident, ..)
4505 | ItemKind::Mod(ident, ..)
4506 | ItemKind::TyAlias(ident, ..)
4507 | ItemKind::Enum(ident, ..)
4508 | ItemKind::Struct(ident, ..)
4509 | ItemKind::Union(ident, ..)
4510 | ItemKind::Trait(_, _, _, ident, ..)
4511 | ItemKind::TraitAlias(_, ident, ..) => Some(ident),
4512
4513 ItemKind::Use(_, UseKind::Glob | UseKind::ListStem)
4514 | ItemKind::ForeignMod { .. }
4515 | ItemKind::GlobalAsm { .. }
4516 | ItemKind::Impl(_) => None,
4517 }
4518 }
4519
4520 pub fn generics(&self) -> Option<&Generics<'_>> {
4521 Some(match self {
4522 ItemKind::Fn { generics, .. }
4523 | ItemKind::TyAlias(_, generics, _)
4524 | ItemKind::Const(_, generics, _, _)
4525 | ItemKind::Enum(_, generics, _)
4526 | ItemKind::Struct(_, generics, _)
4527 | ItemKind::Union(_, generics, _)
4528 | ItemKind::Trait(_, _, _, _, generics, _, _)
4529 | ItemKind::TraitAlias(_, _, generics, _)
4530 | ItemKind::Impl(Impl { generics, .. }) => generics,
4531 _ => return None,
4532 })
4533 }
4534
4535 pub fn recovered(&self) -> bool {
4536 match self {
4537 ItemKind::Struct(
4538 _,
4539 _,
4540 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4541 ) => true,
4542 ItemKind::Union(
4543 _,
4544 _,
4545 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4546 ) => true,
4547 ItemKind::Enum(_, _, def) => def.variants.iter().any(|v| match v.data {
4548 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. } => true,
4549 _ => false,
4550 }),
4551 _ => false,
4552 }
4553 }
4554}
4555
4556#[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_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<OwnerId>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ForeignItemId {
fn encode(&self, __encoder: &mut __E) {
match *self {
ForeignItemId { owner_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ForeignItemId {
fn decode(__decoder: &mut __D) -> Self {
ForeignItemId {
owner_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ForeignItemId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "ForeignItemId",
"owner_id", &&self.owner_id)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ForeignItemId where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ForeignItemId { owner_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4560pub struct ForeignItemId {
4561 pub owner_id: OwnerId,
4562}
4563
4564impl ForeignItemId {
4565 #[inline]
4566 pub fn hir_id(&self) -> HirId {
4567 HirId::make_owner(self.owner_id.def_id)
4569 }
4570}
4571
4572#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ForeignItem<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["ident", "kind", "owner_id", "span", "vis_span",
"has_delayed_lints"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.ident, &self.kind, &self.owner_id, &self.span,
&self.vis_span, &&self.has_delayed_lints];
::core::fmt::Formatter::debug_struct_fields_finish(f, "ForeignItem",
names, values)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ForeignItem<'hir> {
#[inline]
fn clone(&self) -> ForeignItem<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<ForeignItemKind<'hir>>;
let _: ::core::clone::AssertParamIsClone<OwnerId>;
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ForeignItem<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ForeignItem<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ForeignItem {
ident: ref __binding_0,
kind: ref __binding_1,
owner_id: ref __binding_2,
span: ref __binding_3,
vis_span: ref __binding_4,
has_delayed_lints: ref __binding_5 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4573pub struct ForeignItem<'hir> {
4574 pub ident: Ident,
4575 pub kind: ForeignItemKind<'hir>,
4576 pub owner_id: OwnerId,
4577 pub span: Span,
4578 pub vis_span: Span,
4579 pub has_delayed_lints: bool,
4580}
4581
4582impl ForeignItem<'_> {
4583 #[inline]
4584 pub fn hir_id(&self) -> HirId {
4585 HirId::make_owner(self.owner_id.def_id)
4587 }
4588
4589 pub fn foreign_item_id(&self) -> ForeignItemId {
4590 ForeignItemId { owner_id: self.owner_id }
4591 }
4592}
4593
4594#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ForeignItemKind<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ForeignItemKind::Fn(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Fn",
__self_0, __self_1, &__self_2),
ForeignItemKind::Static(__self_0, __self_1, __self_2) =>
::core::fmt::Formatter::debug_tuple_field3_finish(f, "Static",
__self_0, __self_1, &__self_2),
ForeignItemKind::Type =>
::core::fmt::Formatter::write_str(f, "Type"),
}
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ForeignItemKind<'hir> {
#[inline]
fn clone(&self) -> ForeignItemKind<'hir> {
let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir [Option<Ident>]>;
let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _: ::core::clone::AssertParamIsClone<Mutability>;
let _: ::core::clone::AssertParamIsClone<Safety>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ForeignItemKind<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ForeignItemKind<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ForeignItemKind::Fn(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ForeignItemKind::Static(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
ForeignItemKind::Type => {}
}
}
}
};HashStable_Generic)]
4596pub enum ForeignItemKind<'hir> {
4597 Fn(FnSig<'hir>, &'hir [Option<Ident>], &'hir Generics<'hir>),
4604 Static(&'hir Ty<'hir>, Mutability, Safety),
4606 Type,
4608}
4609
4610#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Upvar {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "Upvar", "span",
&&self.span)
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Upvar { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Upvar {
#[inline]
fn clone(&self) -> Upvar {
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Upvar where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Upvar { span: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4612pub struct Upvar {
4613 pub span: Span,
4615}
4616
4617#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TraitCandidate {
#[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 ::core::clone::Clone for TraitCandidate {
#[inline]
fn clone(&self) -> TraitCandidate {
TraitCandidate {
def_id: ::core::clone::Clone::clone(&self.def_id),
import_ids: ::core::clone::Clone::clone(&self.import_ids),
lint_ambiguous: ::core::clone::Clone::clone(&self.lint_ambiguous),
}
}
}Clone, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for TraitCandidate where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitCandidate {
def_id: ref __binding_0,
import_ids: ref __binding_1,
lint_ambiguous: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4621pub struct TraitCandidate {
4622 pub def_id: DefId,
4623 pub import_ids: SmallVec<[LocalDefId; 1]>,
4624 pub lint_ambiguous: bool,
4629}
4630
4631#[derive(#[automatically_derived]
impl<'hir> ::core::marker::Copy for OwnerNode<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::clone::Clone for OwnerNode<'hir> {
#[inline]
fn clone(&self) -> OwnerNode<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Item<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ForeignItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir TraitItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ImplItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Mod<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for OwnerNode<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
OwnerNode::Item(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Item",
&__self_0),
OwnerNode::ForeignItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ForeignItem", &__self_0),
OwnerNode::TraitItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TraitItem", &__self_0),
OwnerNode::ImplItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ImplItem", &__self_0),
OwnerNode::Crate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Crate",
&__self_0),
OwnerNode::Synthetic =>
::core::fmt::Formatter::write_str(f, "Synthetic"),
}
}
}Debug, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
OwnerNode<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
OwnerNode::Item(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
OwnerNode::ForeignItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
OwnerNode::TraitItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
OwnerNode::ImplItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
OwnerNode::Crate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
OwnerNode::Synthetic => {}
}
}
}
};HashStable_Generic)]
4632pub enum OwnerNode<'hir> {
4633 Item(&'hir Item<'hir>),
4634 ForeignItem(&'hir ForeignItem<'hir>),
4635 TraitItem(&'hir TraitItem<'hir>),
4636 ImplItem(&'hir ImplItem<'hir>),
4637 Crate(&'hir Mod<'hir>),
4638 Synthetic,
4639}
4640
4641impl<'hir> OwnerNode<'hir> {
4642 pub fn span(&self) -> Span {
4643 match self {
4644 OwnerNode::Item(Item { span, .. })
4645 | OwnerNode::ForeignItem(ForeignItem { span, .. })
4646 | OwnerNode::ImplItem(ImplItem { span, .. })
4647 | OwnerNode::TraitItem(TraitItem { span, .. }) => *span,
4648 OwnerNode::Crate(Mod { spans: ModSpans { inner_span, .. }, .. }) => *inner_span,
4649 OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4650 }
4651 }
4652
4653 pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
4654 match self {
4655 OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4656 | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4657 | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4658 | OwnerNode::ForeignItem(ForeignItem {
4659 kind: ForeignItemKind::Fn(fn_sig, _, _), ..
4660 }) => Some(fn_sig),
4661 _ => None,
4662 }
4663 }
4664
4665 pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
4666 match self {
4667 OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4668 | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4669 | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4670 | OwnerNode::ForeignItem(ForeignItem {
4671 kind: ForeignItemKind::Fn(fn_sig, _, _), ..
4672 }) => Some(fn_sig.decl),
4673 _ => None,
4674 }
4675 }
4676
4677 pub fn body_id(&self) -> Option<BodyId> {
4678 match self {
4679 OwnerNode::Item(Item {
4680 kind:
4681 ItemKind::Static(_, _, _, body)
4682 | ItemKind::Const(.., ConstItemRhs::Body(body))
4683 | ItemKind::Fn { body, .. },
4684 ..
4685 })
4686 | OwnerNode::TraitItem(TraitItem {
4687 kind:
4688 TraitItemKind::Fn(_, TraitFn::Provided(body))
4689 | TraitItemKind::Const(_, Some(ConstItemRhs::Body(body))),
4690 ..
4691 })
4692 | OwnerNode::ImplItem(ImplItem {
4693 kind: ImplItemKind::Fn(_, body) | ImplItemKind::Const(_, ConstItemRhs::Body(body)),
4694 ..
4695 }) => Some(*body),
4696 _ => None,
4697 }
4698 }
4699
4700 pub fn generics(self) -> Option<&'hir Generics<'hir>> {
4701 Node::generics(self.into())
4702 }
4703
4704 pub fn def_id(self) -> OwnerId {
4705 match self {
4706 OwnerNode::Item(Item { owner_id, .. })
4707 | OwnerNode::TraitItem(TraitItem { owner_id, .. })
4708 | OwnerNode::ImplItem(ImplItem { owner_id, .. })
4709 | OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
4710 OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
4711 OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4712 }
4713 }
4714
4715 pub fn is_impl_block(&self) -> bool {
4717 #[allow(non_exhaustive_omitted_patterns)] match self {
OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }) => true,
_ => false,
}matches!(self, OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }))
4718 }
4719
4720 self
let OwnerNode::TraitItem(n) =
self else { expect_failed("expect_trait_item", self) };
n;expect_methods_self! {
4721 expect_item, &'hir Item<'hir>, OwnerNode::Item(n), n;
4722 expect_foreign_item, &'hir ForeignItem<'hir>, OwnerNode::ForeignItem(n), n;
4723 expect_impl_item, &'hir ImplItem<'hir>, OwnerNode::ImplItem(n), n;
4724 expect_trait_item, &'hir TraitItem<'hir>, OwnerNode::TraitItem(n), n;
4725 }
4726}
4727
4728impl<'hir> From<&'hir Item<'hir>> for OwnerNode<'hir> {
4729 fn from(val: &'hir Item<'hir>) -> Self {
4730 OwnerNode::Item(val)
4731 }
4732}
4733
4734impl<'hir> From<&'hir ForeignItem<'hir>> for OwnerNode<'hir> {
4735 fn from(val: &'hir ForeignItem<'hir>) -> Self {
4736 OwnerNode::ForeignItem(val)
4737 }
4738}
4739
4740impl<'hir> From<&'hir ImplItem<'hir>> for OwnerNode<'hir> {
4741 fn from(val: &'hir ImplItem<'hir>) -> Self {
4742 OwnerNode::ImplItem(val)
4743 }
4744}
4745
4746impl<'hir> From<&'hir TraitItem<'hir>> for OwnerNode<'hir> {
4747 fn from(val: &'hir TraitItem<'hir>) -> Self {
4748 OwnerNode::TraitItem(val)
4749 }
4750}
4751
4752impl<'hir> From<OwnerNode<'hir>> for Node<'hir> {
4753 fn from(val: OwnerNode<'hir>) -> Self {
4754 match val {
4755 OwnerNode::Item(n) => Node::Item(n),
4756 OwnerNode::ForeignItem(n) => Node::ForeignItem(n),
4757 OwnerNode::ImplItem(n) => Node::ImplItem(n),
4758 OwnerNode::TraitItem(n) => Node::TraitItem(n),
4759 OwnerNode::Crate(n) => Node::Crate(n),
4760 OwnerNode::Synthetic => Node::Synthetic,
4761 }
4762 }
4763}
4764
4765#[derive(#[automatically_derived]
impl<'hir> ::core::marker::Copy for Node<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Node<'hir> {
#[inline]
fn clone(&self) -> Node<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir Param<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Item<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ForeignItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir TraitItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ImplItem<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Variant<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir FieldDef<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir AnonConst>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstBlock>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir ExprField<'hir>>;
let _:
::core::clone::AssertParamIsClone<&'hir ConstArgExprField<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Stmt<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir PathSegment<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
let _:
::core::clone::AssertParamIsClone<&'hir AssocItemConstraint<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir TraitRef<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir OpaqueTy<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir TyPat<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir PatField<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir PatExpr<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Arm<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir LetStmt<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir VariantData<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
let _: ::core::clone::AssertParamIsClone<&'hir GenericParam<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir Mod<'hir>>;
let _: ::core::clone::AssertParamIsClone<&'hir InferArg>;
let _: ::core::clone::AssertParamIsClone<&'hir WherePredicate<'hir>>;
let _:
::core::clone::AssertParamIsClone<&'hir PreciseCapturingNonLifetimeArg>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for Node<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Node::Param(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Param",
&__self_0),
Node::Item(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Item",
&__self_0),
Node::ForeignItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ForeignItem", &__self_0),
Node::TraitItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TraitItem", &__self_0),
Node::ImplItem(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ImplItem", &__self_0),
Node::Variant(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Variant", &__self_0),
Node::Field(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Field",
&__self_0),
Node::AnonConst(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"AnonConst", &__self_0),
Node::ConstBlock(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ConstBlock", &__self_0),
Node::ConstArg(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ConstArg", &__self_0),
Node::Expr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Expr",
&__self_0),
Node::ExprField(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ExprField", &__self_0),
Node::ConstArgExprField(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ConstArgExprField", &__self_0),
Node::Stmt(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Stmt",
&__self_0),
Node::PathSegment(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"PathSegment", &__self_0),
Node::Ty(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ty",
&__self_0),
Node::AssocItemConstraint(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"AssocItemConstraint", &__self_0),
Node::TraitRef(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TraitRef", &__self_0),
Node::OpaqueTy(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"OpaqueTy", &__self_0),
Node::TyPat(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "TyPat",
&__self_0),
Node::Pat(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Pat",
&__self_0),
Node::PatField(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"PatField", &__self_0),
Node::PatExpr(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"PatExpr", &__self_0),
Node::Arm(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Arm",
&__self_0),
Node::Block(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Block",
&__self_0),
Node::LetStmt(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"LetStmt", &__self_0),
Node::Ctor(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ctor",
&__self_0),
Node::Lifetime(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Lifetime", &__self_0),
Node::GenericParam(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"GenericParam", &__self_0),
Node::Crate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Crate",
&__self_0),
Node::Infer(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
&__self_0),
Node::WherePredicate(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"WherePredicate", &__self_0),
Node::PreciseCapturingNonLifetimeArg(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"PreciseCapturingNonLifetimeArg", &__self_0),
Node::Synthetic =>
::core::fmt::Formatter::write_str(f, "Synthetic"),
Node::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
}
}
}Debug, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Node<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Node::Param(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Item(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ForeignItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::TraitItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ImplItem(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Variant(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Field(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::AnonConst(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ConstBlock(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ConstArg(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Expr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ExprField(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::ConstArgExprField(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Stmt(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::PathSegment(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Ty(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::AssocItemConstraint(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::TraitRef(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::OpaqueTy(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::TyPat(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Pat(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::PatField(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::PatExpr(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Arm(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Block(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::LetStmt(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Ctor(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Lifetime(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::GenericParam(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Crate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Infer(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::WherePredicate(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::PreciseCapturingNonLifetimeArg(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
Node::Synthetic => {}
Node::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
4766pub enum Node<'hir> {
4767 Param(&'hir Param<'hir>),
4768 Item(&'hir Item<'hir>),
4769 ForeignItem(&'hir ForeignItem<'hir>),
4770 TraitItem(&'hir TraitItem<'hir>),
4771 ImplItem(&'hir ImplItem<'hir>),
4772 Variant(&'hir Variant<'hir>),
4773 Field(&'hir FieldDef<'hir>),
4774 AnonConst(&'hir AnonConst),
4775 ConstBlock(&'hir ConstBlock),
4776 ConstArg(&'hir ConstArg<'hir>),
4777 Expr(&'hir Expr<'hir>),
4778 ExprField(&'hir ExprField<'hir>),
4779 ConstArgExprField(&'hir ConstArgExprField<'hir>),
4780 Stmt(&'hir Stmt<'hir>),
4781 PathSegment(&'hir PathSegment<'hir>),
4782 Ty(&'hir Ty<'hir>),
4783 AssocItemConstraint(&'hir AssocItemConstraint<'hir>),
4784 TraitRef(&'hir TraitRef<'hir>),
4785 OpaqueTy(&'hir OpaqueTy<'hir>),
4786 TyPat(&'hir TyPat<'hir>),
4787 Pat(&'hir Pat<'hir>),
4788 PatField(&'hir PatField<'hir>),
4789 PatExpr(&'hir PatExpr<'hir>),
4793 Arm(&'hir Arm<'hir>),
4794 Block(&'hir Block<'hir>),
4795 LetStmt(&'hir LetStmt<'hir>),
4796 Ctor(&'hir VariantData<'hir>),
4799 Lifetime(&'hir Lifetime),
4800 GenericParam(&'hir GenericParam<'hir>),
4801 Crate(&'hir Mod<'hir>),
4802 Infer(&'hir InferArg),
4803 WherePredicate(&'hir WherePredicate<'hir>),
4804 PreciseCapturingNonLifetimeArg(&'hir PreciseCapturingNonLifetimeArg),
4805 Synthetic,
4807 Err(Span),
4808}
4809
4810impl<'hir> Node<'hir> {
4811 pub fn ident(&self) -> Option<Ident> {
4826 match self {
4827 Node::Item(item) => item.kind.ident(),
4828 Node::TraitItem(TraitItem { ident, .. })
4829 | Node::ImplItem(ImplItem { ident, .. })
4830 | Node::ForeignItem(ForeignItem { ident, .. })
4831 | Node::Field(FieldDef { ident, .. })
4832 | Node::Variant(Variant { ident, .. })
4833 | Node::PathSegment(PathSegment { ident, .. }) => Some(*ident),
4834 Node::Lifetime(lt) => Some(lt.ident),
4835 Node::GenericParam(p) => Some(p.name.ident()),
4836 Node::AssocItemConstraint(c) => Some(c.ident),
4837 Node::PatField(f) => Some(f.ident),
4838 Node::ExprField(f) => Some(f.ident),
4839 Node::ConstArgExprField(f) => Some(f.field),
4840 Node::PreciseCapturingNonLifetimeArg(a) => Some(a.ident),
4841 Node::Param(..)
4842 | Node::AnonConst(..)
4843 | Node::ConstBlock(..)
4844 | Node::ConstArg(..)
4845 | Node::Expr(..)
4846 | Node::Stmt(..)
4847 | Node::Block(..)
4848 | Node::Ctor(..)
4849 | Node::Pat(..)
4850 | Node::TyPat(..)
4851 | Node::PatExpr(..)
4852 | Node::Arm(..)
4853 | Node::LetStmt(..)
4854 | Node::Crate(..)
4855 | Node::Ty(..)
4856 | Node::TraitRef(..)
4857 | Node::OpaqueTy(..)
4858 | Node::Infer(..)
4859 | Node::WherePredicate(..)
4860 | Node::Synthetic
4861 | Node::Err(..) => None,
4862 }
4863 }
4864
4865 pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
4866 match self {
4867 Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4868 | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4869 | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4870 | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
4871 Some(fn_sig.decl)
4872 }
4873 Node::Expr(Expr { kind: ExprKind::Closure(Closure { fn_decl, .. }), .. }) => {
4874 Some(fn_decl)
4875 }
4876 _ => None,
4877 }
4878 }
4879
4880 pub fn impl_block_of_trait(self, trait_def_id: DefId) -> Option<&'hir Impl<'hir>> {
4882 if let Node::Item(Item { kind: ItemKind::Impl(impl_block), .. }) = self
4883 && let Some(of_trait) = impl_block.of_trait
4884 && let Some(trait_id) = of_trait.trait_ref.trait_def_id()
4885 && trait_id == trait_def_id
4886 {
4887 Some(impl_block)
4888 } else {
4889 None
4890 }
4891 }
4892
4893 pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
4894 match self {
4895 Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4896 | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4897 | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4898 | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
4899 Some(fn_sig)
4900 }
4901 _ => None,
4902 }
4903 }
4904
4905 pub fn ty(self) -> Option<&'hir Ty<'hir>> {
4907 match self {
4908 Node::Item(it) => match it.kind {
4909 ItemKind::TyAlias(_, _, ty)
4910 | ItemKind::Static(_, _, ty, _)
4911 | ItemKind::Const(_, _, ty, _) => Some(ty),
4912 ItemKind::Impl(impl_item) => Some(&impl_item.self_ty),
4913 _ => None,
4914 },
4915 Node::TraitItem(it) => match it.kind {
4916 TraitItemKind::Const(ty, _) => Some(ty),
4917 TraitItemKind::Type(_, ty) => ty,
4918 _ => None,
4919 },
4920 Node::ImplItem(it) => match it.kind {
4921 ImplItemKind::Const(ty, _) => Some(ty),
4922 ImplItemKind::Type(ty) => Some(ty),
4923 _ => None,
4924 },
4925 Node::ForeignItem(it) => match it.kind {
4926 ForeignItemKind::Static(ty, ..) => Some(ty),
4927 _ => None,
4928 },
4929 Node::GenericParam(param) => match param.kind {
4930 GenericParamKind::Lifetime { .. } => None,
4931 GenericParamKind::Type { default, .. } => default,
4932 GenericParamKind::Const { ty, .. } => Some(ty),
4933 },
4934 _ => None,
4935 }
4936 }
4937
4938 pub fn alias_ty(self) -> Option<&'hir Ty<'hir>> {
4939 match self {
4940 Node::Item(Item { kind: ItemKind::TyAlias(_, _, ty), .. }) => Some(ty),
4941 _ => None,
4942 }
4943 }
4944
4945 #[inline]
4946 pub fn associated_body(&self) -> Option<(LocalDefId, BodyId)> {
4947 match self {
4948 Node::Item(Item {
4949 owner_id,
4950 kind:
4951 ItemKind::Const(.., ConstItemRhs::Body(body))
4952 | ItemKind::Static(.., body)
4953 | ItemKind::Fn { body, .. },
4954 ..
4955 })
4956 | Node::TraitItem(TraitItem {
4957 owner_id,
4958 kind:
4959 TraitItemKind::Const(.., Some(ConstItemRhs::Body(body)))
4960 | TraitItemKind::Fn(_, TraitFn::Provided(body)),
4961 ..
4962 })
4963 | Node::ImplItem(ImplItem {
4964 owner_id,
4965 kind: ImplItemKind::Const(.., ConstItemRhs::Body(body)) | ImplItemKind::Fn(_, body),
4966 ..
4967 }) => Some((owner_id.def_id, *body)),
4968
4969 Node::Item(Item {
4970 owner_id, kind: ItemKind::GlobalAsm { asm: _, fake_body }, ..
4971 }) => Some((owner_id.def_id, *fake_body)),
4972
4973 Node::Expr(Expr { kind: ExprKind::Closure(Closure { def_id, body, .. }), .. }) => {
4974 Some((*def_id, *body))
4975 }
4976
4977 Node::AnonConst(constant) => Some((constant.def_id, constant.body)),
4978 Node::ConstBlock(constant) => Some((constant.def_id, constant.body)),
4979
4980 _ => None,
4981 }
4982 }
4983
4984 pub fn body_id(&self) -> Option<BodyId> {
4985 Some(self.associated_body()?.1)
4986 }
4987
4988 pub fn generics(self) -> Option<&'hir Generics<'hir>> {
4989 match self {
4990 Node::ForeignItem(ForeignItem {
4991 kind: ForeignItemKind::Fn(_, _, generics), ..
4992 })
4993 | Node::TraitItem(TraitItem { generics, .. })
4994 | Node::ImplItem(ImplItem { generics, .. }) => Some(generics),
4995 Node::Item(item) => item.kind.generics(),
4996 _ => None,
4997 }
4998 }
4999
5000 pub fn as_owner(self) -> Option<OwnerNode<'hir>> {
5001 match self {
5002 Node::Item(i) => Some(OwnerNode::Item(i)),
5003 Node::ForeignItem(i) => Some(OwnerNode::ForeignItem(i)),
5004 Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
5005 Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
5006 Node::Crate(i) => Some(OwnerNode::Crate(i)),
5007 Node::Synthetic => Some(OwnerNode::Synthetic),
5008 _ => None,
5009 }
5010 }
5011
5012 pub fn fn_kind(self) -> Option<FnKind<'hir>> {
5013 match self {
5014 Node::Item(i) => match i.kind {
5015 ItemKind::Fn { ident, sig, generics, .. } => {
5016 Some(FnKind::ItemFn(ident, generics, sig.header))
5017 }
5018 _ => None,
5019 },
5020 Node::TraitItem(ti) => match ti.kind {
5021 TraitItemKind::Fn(ref sig, _) => Some(FnKind::Method(ti.ident, sig)),
5022 _ => None,
5023 },
5024 Node::ImplItem(ii) => match ii.kind {
5025 ImplItemKind::Fn(ref sig, _) => Some(FnKind::Method(ii.ident, sig)),
5026 _ => None,
5027 },
5028 Node::Expr(e) => match e.kind {
5029 ExprKind::Closure { .. } => Some(FnKind::Closure),
5030 _ => None,
5031 },
5032 _ => None,
5033 }
5034 }
5035
5036 self
let Node::Expr(Expr { kind: ExprKind::Closure(n), .. }) =
self else { expect_failed("expect_closure", self) };
n;expect_methods_self! {
5037 expect_param, &'hir Param<'hir>, Node::Param(n), n;
5038 expect_item, &'hir Item<'hir>, Node::Item(n), n;
5039 expect_foreign_item, &'hir ForeignItem<'hir>, Node::ForeignItem(n), n;
5040 expect_trait_item, &'hir TraitItem<'hir>, Node::TraitItem(n), n;
5041 expect_impl_item, &'hir ImplItem<'hir>, Node::ImplItem(n), n;
5042 expect_variant, &'hir Variant<'hir>, Node::Variant(n), n;
5043 expect_field, &'hir FieldDef<'hir>, Node::Field(n), n;
5044 expect_anon_const, &'hir AnonConst, Node::AnonConst(n), n;
5045 expect_inline_const, &'hir ConstBlock, Node::ConstBlock(n), n;
5046 expect_expr, &'hir Expr<'hir>, Node::Expr(n), n;
5047 expect_expr_field, &'hir ExprField<'hir>, Node::ExprField(n), n;
5048 expect_stmt, &'hir Stmt<'hir>, Node::Stmt(n), n;
5049 expect_path_segment, &'hir PathSegment<'hir>, Node::PathSegment(n), n;
5050 expect_ty, &'hir Ty<'hir>, Node::Ty(n), n;
5051 expect_assoc_item_constraint, &'hir AssocItemConstraint<'hir>, Node::AssocItemConstraint(n), n;
5052 expect_trait_ref, &'hir TraitRef<'hir>, Node::TraitRef(n), n;
5053 expect_opaque_ty, &'hir OpaqueTy<'hir>, Node::OpaqueTy(n), n;
5054 expect_pat, &'hir Pat<'hir>, Node::Pat(n), n;
5055 expect_pat_field, &'hir PatField<'hir>, Node::PatField(n), n;
5056 expect_arm, &'hir Arm<'hir>, Node::Arm(n), n;
5057 expect_block, &'hir Block<'hir>, Node::Block(n), n;
5058 expect_let_stmt, &'hir LetStmt<'hir>, Node::LetStmt(n), n;
5059 expect_ctor, &'hir VariantData<'hir>, Node::Ctor(n), n;
5060 expect_lifetime, &'hir Lifetime, Node::Lifetime(n), n;
5061 expect_generic_param, &'hir GenericParam<'hir>, Node::GenericParam(n), n;
5062 expect_crate, &'hir Mod<'hir>, Node::Crate(n), n;
5063 expect_infer, &'hir InferArg, Node::Infer(n), n;
5064 expect_closure, &'hir Closure<'hir>, Node::Expr(Expr { kind: ExprKind::Closure(n), .. }), n;
5065 }
5066}
5067
5068#[cfg(target_pointer_width = "64")]
5070mod size_asserts {
5071 use rustc_data_structures::static_assert_size;
5072
5073 use super::*;
5074 const _: [(); 48] = [(); ::std::mem::size_of::<Block<'_>>()];static_assert_size!(Block<'_>, 48);
5076 const _: [(); 24] = [(); ::std::mem::size_of::<Body<'_>>()];static_assert_size!(Body<'_>, 24);
5077 const _: [(); 64] = [(); ::std::mem::size_of::<Expr<'_>>()];static_assert_size!(Expr<'_>, 64);
5078 const _: [(); 48] = [(); ::std::mem::size_of::<ExprKind<'_>>()];static_assert_size!(ExprKind<'_>, 48);
5079 const _: [(); 40] = [(); ::std::mem::size_of::<FnDecl<'_>>()];static_assert_size!(FnDecl<'_>, 40);
5080 const _: [(); 96] = [(); ::std::mem::size_of::<ForeignItem<'_>>()];static_assert_size!(ForeignItem<'_>, 96);
5081 const _: [(); 56] = [(); ::std::mem::size_of::<ForeignItemKind<'_>>()];static_assert_size!(ForeignItemKind<'_>, 56);
5082 const _: [(); 16] = [(); ::std::mem::size_of::<GenericArg<'_>>()];static_assert_size!(GenericArg<'_>, 16);
5083 const _: [(); 64] = [(); ::std::mem::size_of::<GenericBound<'_>>()];static_assert_size!(GenericBound<'_>, 64);
5084 const _: [(); 56] = [(); ::std::mem::size_of::<Generics<'_>>()];static_assert_size!(Generics<'_>, 56);
5085 const _: [(); 48] = [(); ::std::mem::size_of::<Impl<'_>>()];static_assert_size!(Impl<'_>, 48);
5086 const _: [(); 88] = [(); ::std::mem::size_of::<ImplItem<'_>>()];static_assert_size!(ImplItem<'_>, 88);
5087 const _: [(); 40] = [(); ::std::mem::size_of::<ImplItemKind<'_>>()];static_assert_size!(ImplItemKind<'_>, 40);
5088 const _: [(); 88] = [(); ::std::mem::size_of::<Item<'_>>()];static_assert_size!(Item<'_>, 88);
5089 const _: [(); 64] = [(); ::std::mem::size_of::<ItemKind<'_>>()];static_assert_size!(ItemKind<'_>, 64);
5090 const _: [(); 64] = [(); ::std::mem::size_of::<LetStmt<'_>>()];static_assert_size!(LetStmt<'_>, 64);
5091 const _: [(); 32] = [(); ::std::mem::size_of::<Param<'_>>()];static_assert_size!(Param<'_>, 32);
5092 const _: [(); 80] = [(); ::std::mem::size_of::<Pat<'_>>()];static_assert_size!(Pat<'_>, 80);
5093 const _: [(); 56] = [(); ::std::mem::size_of::<PatKind<'_>>()];static_assert_size!(PatKind<'_>, 56);
5094 const _: [(); 40] = [(); ::std::mem::size_of::<Path<'_>>()];static_assert_size!(Path<'_>, 40);
5095 const _: [(); 48] = [(); ::std::mem::size_of::<PathSegment<'_>>()];static_assert_size!(PathSegment<'_>, 48);
5096 const _: [(); 24] = [(); ::std::mem::size_of::<QPath<'_>>()];static_assert_size!(QPath<'_>, 24);
5097 const _: [(); 12] = [(); ::std::mem::size_of::<Res>()];static_assert_size!(Res, 12);
5098 const _: [(); 32] = [(); ::std::mem::size_of::<Stmt<'_>>()];static_assert_size!(Stmt<'_>, 32);
5099 const _: [(); 16] = [(); ::std::mem::size_of::<StmtKind<'_>>()];static_assert_size!(StmtKind<'_>, 16);
5100 const _: [(); 48] = [(); ::std::mem::size_of::<TraitImplHeader<'_>>()];static_assert_size!(TraitImplHeader<'_>, 48);
5101 const _: [(); 88] = [(); ::std::mem::size_of::<TraitItem<'_>>()];static_assert_size!(TraitItem<'_>, 88);
5102 const _: [(); 48] = [(); ::std::mem::size_of::<TraitItemKind<'_>>()];static_assert_size!(TraitItemKind<'_>, 48);
5103 const _: [(); 48] = [(); ::std::mem::size_of::<Ty<'_>>()];static_assert_size!(Ty<'_>, 48);
5104 const _: [(); 32] = [(); ::std::mem::size_of::<TyKind<'_>>()];static_assert_size!(TyKind<'_>, 32);
5105 }
5107
5108#[cfg(test)]
5109mod tests;