1use std::borrow::Cow;
3use std::fmt;
4
5use rustc_abi::ExternAbi;
6use rustc_ast::attr::AttributeExt;
7use rustc_ast::token::DocFragmentKind;
8use rustc_ast::util::parser::ExprPrecedence;
9use rustc_ast::{
10 self as ast, FloatTy, InlineAsmOptions, InlineAsmTemplatePiece, IntTy, Label, LitIntType,
11 LitKind, TraitObjectSyntax, UintTy, UnsafeBinderCastKind, join_path_idents,
12};
13pub use rustc_ast::{
14 AssignOp, AssignOpKind, AttrId, AttrStyle, BinOp, BinOpKind, BindingMode, BorrowKind,
15 BoundConstness, BoundPolarity, ByRef, CaptureBy, DelimArgs, ImplPolarity, IsAuto,
16 MetaItemInner, MetaItemLit, Movability, Mutability, Pinnedness, UnOp,
17};
18use rustc_data_structures::fingerprint::Fingerprint;
19use rustc_data_structures::sorted_map::SortedMap;
20use rustc_data_structures::tagged_ptr::TaggedRef;
21use rustc_error_messages::{DiagArgValue, IntoDiagArg};
22use rustc_index::IndexVec;
23use rustc_macros::{Decodable, Encodable, HashStable_Generic};
24use rustc_span::def_id::LocalDefId;
25use rustc_span::source_map::Spanned;
26use rustc_span::{
27 BytePos, DUMMY_SP, DesugaringKind, ErrorGuaranteed, Ident, Span, Symbol, kw, sym,
28};
29use rustc_target::asm::InlineAsmRegOrRegClass;
30use smallvec::SmallVec;
31use thin_vec::ThinVec;
32use tracing::debug;
33
34use crate::attrs::AttributeKind;
35use crate::def::{CtorKind, DefKind, MacroKinds, PerNS, Res};
36use crate::def_id::{DefId, LocalDefIdMap};
37pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId};
38use crate::intravisit::{FnKind, VisitorExt};
39use crate::lints::DelayedLints;
40
41#[derive(#[automatically_derived]
impl ::core::fmt::Debug for AngleBrackets {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
AngleBrackets::Missing => "Missing",
AngleBrackets::Empty => "Empty",
AngleBrackets::Full => "Full",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for AngleBrackets { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AngleBrackets {
#[inline]
fn clone(&self) -> AngleBrackets { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for AngleBrackets {
#[inline]
fn eq(&self, other: &AngleBrackets) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for AngleBrackets {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_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)]
42pub enum AngleBrackets {
43 Missing,
45 Empty,
47 Full,
49}
50
51#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LifetimeSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
LifetimeSource::Reference =>
::core::fmt::Formatter::write_str(f, "Reference"),
LifetimeSource::Path { angle_brackets: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Path",
"angle_brackets", &__self_0),
LifetimeSource::OutlivesBound =>
::core::fmt::Formatter::write_str(f, "OutlivesBound"),
LifetimeSource::PreciseCapturing =>
::core::fmt::Formatter::write_str(f, "PreciseCapturing"),
LifetimeSource::Other =>
::core::fmt::Formatter::write_str(f, "Other"),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for LifetimeSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeSource {
#[inline]
fn clone(&self) -> LifetimeSource {
let _: ::core::clone::AssertParamIsClone<AngleBrackets>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LifetimeSource {
#[inline]
fn eq(&self, other: &LifetimeSource) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(LifetimeSource::Path { angle_brackets: __self_0 },
LifetimeSource::Path { angle_brackets: __arg1_0 }) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LifetimeSource {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_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)]
52pub enum LifetimeSource {
53 Reference,
55
56 Path { angle_brackets: AngleBrackets },
59
60 OutlivesBound,
62
63 PreciseCapturing,
65
66 Other,
73}
74
75#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LifetimeSyntax {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
LifetimeSyntax::Implicit => "Implicit",
LifetimeSyntax::ExplicitAnonymous => "ExplicitAnonymous",
LifetimeSyntax::ExplicitBound => "ExplicitBound",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for LifetimeSyntax { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeSyntax {
#[inline]
fn clone(&self) -> LifetimeSyntax { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LifetimeSyntax {
#[inline]
fn eq(&self, other: &LifetimeSyntax) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LifetimeSyntax {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_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)]
76pub enum LifetimeSyntax {
77 Implicit,
79
80 ExplicitAnonymous,
82
83 ExplicitBound,
85}
86
87impl From<Ident> for LifetimeSyntax {
88 fn from(ident: Ident) -> Self {
89 let name = ident.name;
90
91 if name == sym::empty {
92 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("A lifetime name should never be empty")));
};unreachable!("A lifetime name should never be empty");
93 } else if name == kw::UnderscoreLifetime {
94 LifetimeSyntax::ExplicitAnonymous
95 } else {
96 if true {
if !name.as_str().starts_with('\'') {
::core::panicking::panic("assertion failed: name.as_str().starts_with(\'\\\'\')")
};
};debug_assert!(name.as_str().starts_with('\''));
97 LifetimeSyntax::ExplicitBound
98 }
99 }
100}
101
102#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Lifetime {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Lifetime",
"hir_id", &self.hir_id, "ident", &self.ident, "kind", &self.kind,
"source", &self.source, "syntax", &&self.syntax)
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Lifetime { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Lifetime {
#[inline]
fn clone(&self) -> Lifetime {
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<LifetimeKind>;
let _: ::core::clone::AssertParamIsClone<LifetimeSource>;
let _: ::core::clone::AssertParamIsClone<LifetimeSyntax>;
*self
}
}Clone, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Lifetime where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Lifetime {
hir_id: ref __binding_0,
ident: ref __binding_1,
kind: ref __binding_2,
source: ref __binding_3,
syntax: ref __binding_4 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
153#[repr(align(4))]
161pub struct Lifetime {
162 #[stable_hasher(ignore)]
163 pub hir_id: HirId,
164
165 pub ident: Ident,
169
170 pub kind: LifetimeKind,
172
173 pub source: LifetimeSource,
176
177 pub syntax: LifetimeSyntax,
180}
181
182#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ParamName {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ParamName::Plain(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Plain",
&__self_0),
ParamName::Error(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Error",
&__self_0),
ParamName::Fresh => ::core::fmt::Formatter::write_str(f, "Fresh"),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for ParamName { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ParamName {
#[inline]
fn clone(&self) -> ParamName {
let _: ::core::clone::AssertParamIsClone<Ident>;
*self
}
}Clone, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ParamName where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ParamName::Plain(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ParamName::Error(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ParamName::Fresh => {}
}
}
}
};HashStable_Generic)]
183pub enum ParamName {
184 Plain(Ident),
186
187 Error(Ident),
193
194 Fresh,
209}
210
211impl ParamName {
212 pub fn ident(&self) -> Ident {
213 match *self {
214 ParamName::Plain(ident) | ParamName::Error(ident) => ident,
215 ParamName::Fresh => Ident::with_dummy_span(kw::UnderscoreLifetime),
216 }
217 }
218}
219
220#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LifetimeKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
LifetimeKind::Param(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Param",
&__self_0),
LifetimeKind::ImplicitObjectLifetimeDefault =>
::core::fmt::Formatter::write_str(f,
"ImplicitObjectLifetimeDefault"),
LifetimeKind::Error =>
::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)]
221pub enum LifetimeKind {
222 Param(LocalDefId),
224
225 ImplicitObjectLifetimeDefault,
237
238 Error,
241
242 Infer,
246
247 Static,
249}
250
251impl LifetimeKind {
252 fn is_elided(&self) -> bool {
253 match self {
254 LifetimeKind::ImplicitObjectLifetimeDefault | LifetimeKind::Infer => true,
255
256 LifetimeKind::Error | LifetimeKind::Param(..) | LifetimeKind::Static => false,
261 }
262 }
263}
264
265impl fmt::Display for Lifetime {
266 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
267 self.ident.name.fmt(f)
268 }
269}
270
271impl Lifetime {
272 pub fn new(
273 hir_id: HirId,
274 ident: Ident,
275 kind: LifetimeKind,
276 source: LifetimeSource,
277 syntax: LifetimeSyntax,
278 ) -> Lifetime {
279 let lifetime = Lifetime { hir_id, ident, kind, source, syntax };
280
281 #[cfg(debug_assertions)]
283 match (lifetime.is_elided(), lifetime.is_anonymous()) {
284 (false, false) => {} (false, true) => {} (true, true) => {} (true, false) => { ::core::panicking::panic_fmt(format_args!("bad Lifetime")); }panic!("bad Lifetime"),
288 }
289
290 lifetime
291 }
292
293 pub fn is_elided(&self) -> bool {
294 self.kind.is_elided()
295 }
296
297 pub fn is_anonymous(&self) -> bool {
298 self.ident.name == kw::UnderscoreLifetime
299 }
300
301 pub fn is_implicit(&self) -> bool {
302 #[allow(non_exhaustive_omitted_patterns)] match self.syntax {
LifetimeSyntax::Implicit => true,
_ => false,
}matches!(self.syntax, LifetimeSyntax::Implicit)
303 }
304
305 pub fn is_static(&self) -> bool {
306 self.kind == LifetimeKind::Static
307 }
308
309 pub fn suggestion(&self, new_lifetime: &str) -> (Span, String) {
310 use LifetimeSource::*;
311 use LifetimeSyntax::*;
312
313 if true {
if !new_lifetime.starts_with('\'') {
::core::panicking::panic("assertion failed: new_lifetime.starts_with(\'\\\'\')")
};
};debug_assert!(new_lifetime.starts_with('\''));
314
315 match (self.syntax, self.source) {
316 (ExplicitBound | ExplicitAnonymous, _) => (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", new_lifetime))
})format!("{new_lifetime}")),
318
319 (Implicit, Path { angle_brackets: AngleBrackets::Full }) => {
321 (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}, ", new_lifetime))
})format!("{new_lifetime}, "))
322 }
323
324 (Implicit, Path { angle_brackets: AngleBrackets::Empty }) => {
326 (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", new_lifetime))
})format!("{new_lifetime}"))
327 }
328
329 (Implicit, Path { angle_brackets: AngleBrackets::Missing }) => {
331 (self.ident.span.shrink_to_hi(), ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("<{0}>", new_lifetime))
})format!("<{new_lifetime}>"))
332 }
333
334 (Implicit, Reference) => (self.ident.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} ", new_lifetime))
})format!("{new_lifetime} ")),
336
337 (Implicit, source) => {
338 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("can\'t suggest for a implicit lifetime of {0:?}",
source)));
}unreachable!("can't suggest for a implicit lifetime of {source:?}")
339 }
340 }
341 }
342}
343
344#[derive(#[automatically_derived]
impl<'hir, R: ::core::fmt::Debug> ::core::fmt::Debug for Path<'hir, R> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "Path", "span",
&self.span, "res", &self.res, "segments", &&self.segments)
}
}Debug, #[automatically_derived]
impl<'hir, R: ::core::clone::Clone> ::core::clone::Clone for Path<'hir, R> {
#[inline]
fn clone(&self) -> Path<'hir, R> {
Path {
span: ::core::clone::Clone::clone(&self.span),
res: ::core::clone::Clone::clone(&self.res),
segments: ::core::clone::Clone::clone(&self.segments),
}
}
}Clone, #[automatically_derived]
impl<'hir, R: ::core::marker::Copy> ::core::marker::Copy for Path<'hir, R> { }Copy, const _: () =
{
impl<'hir, R, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Path<'hir, R> where __CTX: crate::HashStableContext,
R: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Path {
span: ref __binding_0,
res: ref __binding_1,
segments: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
348pub struct Path<'hir, R = Res> {
349 pub span: Span,
350 pub res: R,
352 pub segments: &'hir [PathSegment<'hir>],
354}
355
356pub type UsePath<'hir> = Path<'hir, PerNS<Option<Res>>>;
358
359impl Path<'_> {
360 pub fn is_global(&self) -> bool {
361 self.segments.first().is_some_and(|segment| segment.ident.name == kw::PathRoot)
362 }
363}
364
365#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PathSegment<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "PathSegment",
"ident", &self.ident, "hir_id", &self.hir_id, "res", &self.res,
"args", &self.args, "infer_args", &&self.infer_args)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PathSegment<'hir> {
#[inline]
fn clone(&self) -> PathSegment<'hir> {
let _: ::core::clone::AssertParamIsClone<Ident>;
let _: ::core::clone::AssertParamIsClone<HirId>;
let _: ::core::clone::AssertParamIsClone<Res>;
let _:
::core::clone::AssertParamIsClone<Option<&'hir GenericArgs<'hir>>>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PathSegment<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
PathSegment<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
PathSegment {
ident: ref __binding_0,
hir_id: ref __binding_1,
res: ref __binding_2,
args: ref __binding_3,
infer_args: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{}
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
368pub struct PathSegment<'hir> {
369 pub ident: Ident,
371 #[stable_hasher(ignore)]
372 pub hir_id: HirId,
373 pub res: Res,
374
375 pub args: Option<&'hir GenericArgs<'hir>>,
381
382 pub infer_args: bool,
387}
388
389impl<'hir> PathSegment<'hir> {
390 pub fn new(ident: Ident, hir_id: HirId, res: Res) -> PathSegment<'hir> {
392 PathSegment { ident, hir_id, res, infer_args: true, args: None }
393 }
394
395 pub fn invalid() -> Self {
396 Self::new(Ident::dummy(), HirId::INVALID, Res::Err)
397 }
398
399 pub fn args(&self) -> &GenericArgs<'hir> {
400 if let Some(ref args) = self.args {
401 args
402 } else {
403 const DUMMY: &GenericArgs<'_> = &GenericArgs::none();
404 DUMMY
405 }
406 }
407}
408
409#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for ConstItemRhs<'hir> {
#[inline]
fn clone(&self) -> ConstItemRhs<'hir> {
let _: ::core::clone::AssertParamIsClone<BodyId>;
let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ConstItemRhs<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for ConstItemRhs<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ConstItemRhs::Body(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Body",
&__self_0),
ConstItemRhs::TypeConst(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"TypeConst", &__self_0),
}
}
}Debug, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstItemRhs<'hir> where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ConstItemRhs::Body(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ConstItemRhs::TypeConst(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
410pub enum ConstItemRhs<'hir> {
411 Body(BodyId),
412 TypeConst(&'hir ConstArg<'hir>),
413}
414
415impl<'hir> ConstItemRhs<'hir> {
416 pub fn hir_id(&self) -> HirId {
417 match self {
418 ConstItemRhs::Body(body_id) => body_id.hir_id,
419 ConstItemRhs::TypeConst(ct_arg) => ct_arg.hir_id,
420 }
421 }
422
423 pub fn span<'tcx>(&self, tcx: impl crate::intravisit::HirTyCtxt<'tcx>) -> Span {
424 match self {
425 ConstItemRhs::Body(body_id) => tcx.hir_body(*body_id).value.span,
426 ConstItemRhs::TypeConst(ct_arg) => ct_arg.span,
427 }
428 }
429}
430
431#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
ConstArg<'hir, Unambig> {
#[inline]
fn clone(&self) -> ConstArg<'hir, Unambig> {
ConstArg {
hir_id: ::core::clone::Clone::clone(&self.hir_id),
kind: ::core::clone::Clone::clone(&self.kind),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
ConstArg<'hir, Unambig> {
}Copy, #[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
ConstArg<'hir, Unambig> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "ConstArg",
"hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
}
}Debug, const _: () =
{
impl<'hir, Unambig, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
ConstArg<'hir, Unambig> where __CTX: crate::HashStableContext,
Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ConstArg {
hir_id: ref __binding_0,
kind: ref __binding_1,
span: ref __binding_2 } => {
{}
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
445#[repr(C)]
446pub struct ConstArg<'hir, Unambig = ()> {
447 #[stable_hasher(ignore)]
448 pub hir_id: HirId,
449 pub kind: ConstArgKind<'hir, Unambig>,
450 pub span: Span,
451}
452
453impl<'hir> ConstArg<'hir, AmbigArg> {
454 pub fn as_unambig_ct(&self) -> &ConstArg<'hir> {
465 let ptr = self as *const ConstArg<'hir, AmbigArg> as *const ConstArg<'hir, ()>;
468 unsafe { &*ptr }
469 }
470}
471
472impl<'hir> ConstArg<'hir> {
473 pub fn try_as_ambig_ct(&self) -> Option<&ConstArg<'hir, AmbigArg>> {
479 if let ConstArgKind::Infer(()) = self.kind {
480 return None;
481 }
482
483 let ptr = self as *const ConstArg<'hir> as *const ConstArg<'hir, AmbigArg>;
487 Some(unsafe { &*ptr })
488 }
489}
490
491impl<'hir, Unambig> ConstArg<'hir, Unambig> {
492 pub fn anon_const_hir_id(&self) -> Option<HirId> {
493 match self.kind {
494 ConstArgKind::Anon(ac) => Some(ac.hir_id),
495 _ => None,
496 }
497 }
498}
499
500#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
ConstArgKind<'hir, Unambig> {
#[inline]
fn clone(&self) -> ConstArgKind<'hir, Unambig> {
match self {
ConstArgKind::Tup(__self_0) =>
ConstArgKind::Tup(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Path(__self_0) =>
ConstArgKind::Path(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Anon(__self_0) =>
ConstArgKind::Anon(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Struct(__self_0, __self_1) =>
ConstArgKind::Struct(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
ConstArgKind::TupleCall(__self_0, __self_1) =>
ConstArgKind::TupleCall(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
ConstArgKind::Array(__self_0) =>
ConstArgKind::Array(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Error(__self_0) =>
ConstArgKind::Error(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Infer(__self_0) =>
ConstArgKind::Infer(::core::clone::Clone::clone(__self_0)),
ConstArgKind::Literal(__self_0) =>
ConstArgKind::Literal(::core::clone::Clone::clone(__self_0)),
}
}
}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(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Literal", &__self_0),
}
}
}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(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
502#[repr(u8, C)]
503pub enum ConstArgKind<'hir, Unambig = ()> {
504 Tup(&'hir [&'hir ConstArg<'hir, Unambig>]),
505 Path(QPath<'hir>),
511 Anon(&'hir AnonConst),
512 Struct(QPath<'hir>, &'hir [&'hir ConstArgExprField<'hir>]),
514 TupleCall(QPath<'hir>, &'hir [&'hir ConstArg<'hir>]),
516 Array(&'hir ConstArgArrayExpr<'hir>),
518 Error(ErrorGuaranteed),
520 Infer(Unambig),
523 Literal(LitKind),
524}
525
526#[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)]
527pub struct ConstArgExprField<'hir> {
528 pub hir_id: HirId,
529 pub span: Span,
530 pub field: Ident,
531 pub expr: &'hir ConstArg<'hir>,
532}
533
534#[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)]
535pub struct ConstArgArrayExpr<'hir> {
536 pub span: Span,
537 pub elems: &'hir [&'hir ConstArg<'hir>],
538}
539
540#[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)]
541pub struct InferArg {
542 #[stable_hasher(ignore)]
543 pub hir_id: HirId,
544 pub span: Span,
545}
546
547impl InferArg {
548 pub fn to_ty(&self) -> Ty<'static> {
549 Ty { kind: TyKind::Infer(()), span: self.span, hir_id: self.hir_id }
550 }
551}
552
553#[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)]
554pub enum GenericArg<'hir> {
555 Lifetime(&'hir Lifetime),
556 Type(&'hir Ty<'hir, AmbigArg>),
557 Const(&'hir ConstArg<'hir, AmbigArg>),
558 Infer(InferArg),
568}
569
570impl GenericArg<'_> {
571 pub fn span(&self) -> Span {
572 match self {
573 GenericArg::Lifetime(l) => l.ident.span,
574 GenericArg::Type(t) => t.span,
575 GenericArg::Const(c) => c.span,
576 GenericArg::Infer(i) => i.span,
577 }
578 }
579
580 pub fn hir_id(&self) -> HirId {
581 match self {
582 GenericArg::Lifetime(l) => l.hir_id,
583 GenericArg::Type(t) => t.hir_id,
584 GenericArg::Const(c) => c.hir_id,
585 GenericArg::Infer(i) => i.hir_id,
586 }
587 }
588
589 pub fn descr(&self) -> &'static str {
590 match self {
591 GenericArg::Lifetime(_) => "lifetime",
592 GenericArg::Type(_) => "type",
593 GenericArg::Const(_) => "constant",
594 GenericArg::Infer(_) => "placeholder",
595 }
596 }
597
598 pub fn to_ord(&self) -> ast::ParamKindOrd {
599 match self {
600 GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime,
601 GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => {
602 ast::ParamKindOrd::TypeOrConst
603 }
604 }
605 }
606
607 pub fn is_ty_or_const(&self) -> bool {
608 match self {
609 GenericArg::Lifetime(_) => false,
610 GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => true,
611 }
612 }
613}
614
615#[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)]
617pub struct GenericArgs<'hir> {
618 pub args: &'hir [GenericArg<'hir>],
620 pub constraints: &'hir [AssocItemConstraint<'hir>],
622 pub parenthesized: GenericArgsParentheses,
627 pub span_ext: Span,
640}
641
642impl<'hir> GenericArgs<'hir> {
643 pub const fn none() -> Self {
644 Self {
645 args: &[],
646 constraints: &[],
647 parenthesized: GenericArgsParentheses::No,
648 span_ext: DUMMY_SP,
649 }
650 }
651
652 pub fn paren_sugar_inputs_output(&self) -> Option<(&[Ty<'hir>], &Ty<'hir>)> {
657 if self.parenthesized != GenericArgsParentheses::ParenSugar {
658 return None;
659 }
660
661 let inputs = self
662 .args
663 .iter()
664 .find_map(|arg| {
665 let GenericArg::Type(ty) = arg else { return None };
666 let TyKind::Tup(tys) = &ty.kind else { return None };
667 Some(tys)
668 })
669 .unwrap();
670
671 Some((inputs, self.paren_sugar_output_inner()))
672 }
673
674 pub fn paren_sugar_output(&self) -> Option<&Ty<'hir>> {
679 (self.parenthesized == GenericArgsParentheses::ParenSugar)
680 .then(|| self.paren_sugar_output_inner())
681 }
682
683 fn paren_sugar_output_inner(&self) -> &Ty<'hir> {
684 let [constraint] = self.constraints.try_into().unwrap();
685 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);
686 constraint.ty().unwrap()
687 }
688
689 pub fn has_err(&self) -> Option<ErrorGuaranteed> {
690 self.args
691 .iter()
692 .find_map(|arg| {
693 let GenericArg::Type(ty) = arg else { return None };
694 let TyKind::Err(guar) = ty.kind else { return None };
695 Some(guar)
696 })
697 .or_else(|| {
698 self.constraints.iter().find_map(|constraint| {
699 let TyKind::Err(guar) = constraint.ty()?.kind else { return None };
700 Some(guar)
701 })
702 })
703 }
704
705 #[inline]
706 pub fn num_lifetime_params(&self) -> usize {
707 self.args.iter().filter(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
708 }
709
710 #[inline]
711 pub fn has_lifetime_params(&self) -> bool {
712 self.args.iter().any(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_)))
713 }
714
715 #[inline]
716 pub fn num_generic_params(&self) -> usize {
719 self.args.iter().filter(|arg| !#[allow(non_exhaustive_omitted_patterns)] match arg {
GenericArg::Lifetime(_) => true,
_ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
720 }
721
722 pub fn span(&self) -> Option<Span> {
728 let span_ext = self.span_ext()?;
729 Some(span_ext.with_lo(span_ext.lo() + BytePos(1)).with_hi(span_ext.hi() - BytePos(1)))
730 }
731
732 pub fn span_ext(&self) -> Option<Span> {
734 Some(self.span_ext).filter(|span| !span.is_empty())
735 }
736
737 pub fn is_empty(&self) -> bool {
738 self.args.is_empty()
739 }
740}
741
742#[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)]
743pub enum GenericArgsParentheses {
744 No,
745 ReturnTypeNotation,
748 ParenSugar,
750}
751
752#[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)]
754pub struct TraitBoundModifiers {
755 pub constness: BoundConstness,
756 pub polarity: BoundPolarity,
757}
758
759impl TraitBoundModifiers {
760 pub const NONE: Self =
761 TraitBoundModifiers { constness: BoundConstness::Never, polarity: BoundPolarity::Positive };
762}
763
764#[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)]
765pub enum GenericBound<'hir> {
766 Trait(PolyTraitRef<'hir>),
767 Outlives(&'hir Lifetime),
768 Use(&'hir [PreciseCapturingArg<'hir>], Span),
769}
770
771impl GenericBound<'_> {
772 pub fn trait_ref(&self) -> Option<&TraitRef<'_>> {
773 match self {
774 GenericBound::Trait(data) => Some(&data.trait_ref),
775 _ => None,
776 }
777 }
778
779 pub fn span(&self) -> Span {
780 match self {
781 GenericBound::Trait(t, ..) => t.span,
782 GenericBound::Outlives(l) => l.ident.span,
783 GenericBound::Use(_, span) => *span,
784 }
785 }
786}
787
788pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>];
789
790#[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)]
791pub enum MissingLifetimeKind {
792 Underscore,
794 Ampersand,
796 Comma,
798 Brackets,
800}
801
802#[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)]
803pub enum LifetimeParamKind {
804 Explicit,
807
808 Elided(MissingLifetimeKind),
811
812 Error,
814}
815
816#[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)]
817pub enum GenericParamKind<'hir> {
818 Lifetime {
820 kind: LifetimeParamKind,
821 },
822 Type {
823 default: Option<&'hir Ty<'hir>>,
824 synthetic: bool,
825 },
826 Const {
827 ty: &'hir Ty<'hir>,
828 default: Option<&'hir ConstArg<'hir>>,
830 },
831}
832
833#[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)]
834pub struct GenericParam<'hir> {
835 #[stable_hasher(ignore)]
836 pub hir_id: HirId,
837 pub def_id: LocalDefId,
838 pub name: ParamName,
839 pub span: Span,
840 pub pure_wrt_drop: bool,
841 pub kind: GenericParamKind<'hir>,
842 pub colon_span: Option<Span>,
843 pub source: GenericParamSource,
844}
845
846impl<'hir> GenericParam<'hir> {
847 pub fn is_impl_trait(&self) -> bool {
851 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Type { synthetic: true, .. } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Type { synthetic: true, .. })
852 }
853
854 pub fn is_elided_lifetime(&self) -> bool {
858 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) } => true,
_ => false,
}matches!(self.kind, GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) })
859 }
860}
861
862#[derive(#[automatically_derived]
impl ::core::fmt::Debug for GenericParamSource {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
GenericParamSource::Generics => "Generics",
GenericParamSource::Binder => "Binder",
})
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for GenericParamSource {
#[inline]
fn clone(&self) -> GenericParamSource { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for GenericParamSource { }Copy, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for GenericParamSource where __CTX: 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)]
869pub enum GenericParamSource {
870 Generics,
872 Binder,
874}
875
876#[derive(#[automatically_derived]
impl ::core::default::Default for GenericParamCount {
#[inline]
fn default() -> GenericParamCount {
GenericParamCount {
lifetimes: ::core::default::Default::default(),
types: ::core::default::Default::default(),
consts: ::core::default::Default::default(),
infer: ::core::default::Default::default(),
}
}
}Default)]
877pub struct GenericParamCount {
878 pub lifetimes: usize,
879 pub types: usize,
880 pub consts: usize,
881 pub infer: usize,
882}
883
884#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Generics<'hir> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "Generics",
"params", &self.params, "predicates", &self.predicates,
"has_where_clause_predicates", &self.has_where_clause_predicates,
"where_clause_span", &self.where_clause_span, "span", &&self.span)
}
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Generics<'hir> {
#[inline]
fn clone(&self) -> Generics<'hir> {
let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
let _:
::core::clone::AssertParamIsClone<&'hir [WherePredicate<'hir>]>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Generics<'hir> { }Copy, const _: () =
{
impl<'hir, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
Generics<'hir> where __CTX: 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)]
887pub struct Generics<'hir> {
888 pub params: &'hir [GenericParam<'hir>],
889 pub predicates: &'hir [WherePredicate<'hir>],
890 pub has_where_clause_predicates: bool,
891 pub where_clause_span: Span,
892 pub span: Span,
893}
894
895impl<'hir> Generics<'hir> {
896 pub const fn empty() -> &'hir Generics<'hir> {
897 const NOPE: Generics<'_> = Generics {
898 params: &[],
899 predicates: &[],
900 has_where_clause_predicates: false,
901 where_clause_span: DUMMY_SP,
902 span: DUMMY_SP,
903 };
904 &NOPE
905 }
906
907 pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'hir>> {
908 self.params.iter().find(|¶m| name == param.name.ident().name)
909 }
910
911 pub fn span_for_lifetime_suggestion(&self) -> Option<Span> {
913 if let Some(first) = self.params.first()
914 && self.span.contains(first.span)
915 {
916 Some(first.span.shrink_to_lo())
919 } else {
920 None
921 }
922 }
923
924 pub fn span_for_param_suggestion(&self) -> Option<Span> {
926 self.params.iter().any(|p| self.span.contains(p.span)).then(|| {
927 self.span.with_lo(self.span.hi() - BytePos(1)).shrink_to_lo()
930 })
931 }
932
933 pub fn tail_span_for_predicate_suggestion(&self) -> Span {
936 let end = self.where_clause_span.shrink_to_hi();
937 if self.has_where_clause_predicates {
938 self.predicates
939 .iter()
940 .rfind(|&p| p.kind.in_where_clause())
941 .map_or(end, |p| p.span)
942 .shrink_to_hi()
943 .to(end)
944 } else {
945 end
946 }
947 }
948
949 pub fn add_where_or_trailing_comma(&self) -> &'static str {
950 if self.has_where_clause_predicates {
951 ","
952 } else if self.where_clause_span.is_empty() {
953 " where"
954 } else {
955 ""
957 }
958 }
959
960 pub fn bounds_for_param(
961 &self,
962 param_def_id: LocalDefId,
963 ) -> impl Iterator<Item = &WhereBoundPredicate<'hir>> {
964 self.predicates.iter().filter_map(move |pred| match pred.kind {
965 WherePredicateKind::BoundPredicate(bp)
966 if bp.is_param_bound(param_def_id.to_def_id()) =>
967 {
968 Some(bp)
969 }
970 _ => None,
971 })
972 }
973
974 pub fn outlives_for_param(
975 &self,
976 param_def_id: LocalDefId,
977 ) -> impl Iterator<Item = &WhereRegionPredicate<'_>> {
978 self.predicates.iter().filter_map(move |pred| match pred.kind {
979 WherePredicateKind::RegionPredicate(rp) if rp.is_param_bound(param_def_id) => Some(rp),
980 _ => None,
981 })
982 }
983
984 pub fn bounds_span_for_suggestions(
995 &self,
996 param_def_id: LocalDefId,
997 ) -> Option<(Span, Option<Span>)> {
998 self.bounds_for_param(param_def_id).flat_map(|bp| bp.bounds.iter().rev()).find_map(
999 |bound| {
1000 let span_for_parentheses = if let Some(trait_ref) = bound.trait_ref()
1001 && let [.., segment] = trait_ref.path.segments
1002 && let Some(ret_ty) = segment.args().paren_sugar_output()
1003 && let ret_ty = ret_ty.peel_refs()
1004 && let TyKind::TraitObject(_, tagged_ptr) = ret_ty.kind
1005 && let TraitObjectSyntax::Dyn = tagged_ptr.tag()
1006 && ret_ty.span.can_be_used_for_suggestions()
1007 {
1008 Some(ret_ty.span)
1009 } else {
1010 None
1011 };
1012
1013 span_for_parentheses.map_or_else(
1014 || {
1015 let bs = bound.span();
1018 bs.can_be_used_for_suggestions().then(|| (bs.shrink_to_hi(), None))
1019 },
1020 |span| Some((span.shrink_to_hi(), Some(span.shrink_to_lo()))),
1021 )
1022 },
1023 )
1024 }
1025
1026 pub fn span_for_predicate_removal(&self, pos: usize) -> Span {
1027 let predicate = &self.predicates[pos];
1028 let span = predicate.span;
1029
1030 if !predicate.kind.in_where_clause() {
1031 return span;
1034 }
1035
1036 if pos < self.predicates.len() - 1 {
1038 let next_pred = &self.predicates[pos + 1];
1039 if next_pred.kind.in_where_clause() {
1040 return span.until(next_pred.span);
1043 }
1044 }
1045
1046 if pos > 0 {
1047 let prev_pred = &self.predicates[pos - 1];
1048 if prev_pred.kind.in_where_clause() {
1049 return prev_pred.span.shrink_to_hi().to(span);
1052 }
1053 }
1054
1055 self.where_clause_span
1059 }
1060
1061 pub fn span_for_bound_removal(&self, predicate_pos: usize, bound_pos: usize) -> Span {
1062 let predicate = &self.predicates[predicate_pos];
1063 let bounds = predicate.kind.bounds();
1064
1065 if bounds.len() == 1 {
1066 return self.span_for_predicate_removal(predicate_pos);
1067 }
1068
1069 let bound_span = bounds[bound_pos].span();
1070 if bound_pos < bounds.len() - 1 {
1071 bound_span.to(bounds[bound_pos + 1].span().shrink_to_lo())
1077 } else {
1078 bound_span.with_lo(bounds[bound_pos - 1].span().hi())
1084 }
1085 }
1086}
1087
1088#[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)]
1090pub struct WherePredicate<'hir> {
1091 #[stable_hasher(ignore)]
1092 pub hir_id: HirId,
1093 pub span: Span,
1094 pub kind: &'hir WherePredicateKind<'hir>,
1095}
1096
1097#[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)]
1099pub enum WherePredicateKind<'hir> {
1100 BoundPredicate(WhereBoundPredicate<'hir>),
1102 RegionPredicate(WhereRegionPredicate<'hir>),
1104 EqPredicate(WhereEqPredicate<'hir>),
1106}
1107
1108impl<'hir> WherePredicateKind<'hir> {
1109 pub fn in_where_clause(&self) -> bool {
1110 match self {
1111 WherePredicateKind::BoundPredicate(p) => p.origin == PredicateOrigin::WhereClause,
1112 WherePredicateKind::RegionPredicate(p) => p.in_where_clause,
1113 WherePredicateKind::EqPredicate(_) => false,
1114 }
1115 }
1116
1117 pub fn bounds(&self) -> GenericBounds<'hir> {
1118 match self {
1119 WherePredicateKind::BoundPredicate(p) => p.bounds,
1120 WherePredicateKind::RegionPredicate(p) => p.bounds,
1121 WherePredicateKind::EqPredicate(_) => &[],
1122 }
1123 }
1124}
1125
1126#[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)]
1127pub enum PredicateOrigin {
1128 WhereClause,
1129 GenericParam,
1130 ImplTrait,
1131}
1132
1133#[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)]
1135pub struct WhereBoundPredicate<'hir> {
1136 pub origin: PredicateOrigin,
1138 pub bound_generic_params: &'hir [GenericParam<'hir>],
1140 pub bounded_ty: &'hir Ty<'hir>,
1142 pub bounds: GenericBounds<'hir>,
1144}
1145
1146impl<'hir> WhereBoundPredicate<'hir> {
1147 pub fn is_param_bound(&self, param_def_id: DefId) -> bool {
1149 self.bounded_ty.as_generic_param().is_some_and(|(def_id, _)| def_id == param_def_id)
1150 }
1151}
1152
1153#[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)]
1155pub struct WhereRegionPredicate<'hir> {
1156 pub in_where_clause: bool,
1157 pub lifetime: &'hir Lifetime,
1158 pub bounds: GenericBounds<'hir>,
1159}
1160
1161impl<'hir> WhereRegionPredicate<'hir> {
1162 fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
1164 self.lifetime.kind == LifetimeKind::Param(param_def_id)
1165 }
1166}
1167
1168#[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)]
1170pub struct WhereEqPredicate<'hir> {
1171 pub lhs_ty: &'hir Ty<'hir>,
1172 pub rhs_ty: &'hir Ty<'hir>,
1173}
1174
1175#[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)]
1179pub struct ParentedNode<'tcx> {
1180 pub parent: ItemLocalId,
1181 pub node: Node<'tcx>,
1182}
1183
1184#[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)]
1186pub enum AttrArgs {
1187 Empty,
1189 Delimited(DelimArgs),
1191 Eq {
1193 eq_span: Span,
1195 expr: MetaItemLit,
1197 },
1198}
1199
1200#[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)]
1201pub struct AttrPath {
1202 pub segments: Box<[Symbol]>,
1203 pub span: Span,
1204}
1205
1206impl IntoDiagArg for AttrPath {
1207 fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>) -> DiagArgValue {
1208 self.to_string().into_diag_arg(path)
1209 }
1210}
1211
1212impl AttrPath {
1213 pub fn from_ast(path: &ast::Path, lower_span: impl Copy + Fn(Span) -> Span) -> Self {
1214 AttrPath {
1215 segments: path
1216 .segments
1217 .iter()
1218 .map(|i| i.ident.name)
1219 .collect::<Vec<_>>()
1220 .into_boxed_slice(),
1221 span: lower_span(path.span),
1222 }
1223 }
1224}
1225
1226impl fmt::Display for AttrPath {
1227 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1228 f.write_fmt(format_args!("{0}",
join_path_idents(self.segments.iter().map(|i|
Ident { name: *i, span: DUMMY_SP }))))write!(
1229 f,
1230 "{}",
1231 join_path_idents(self.segments.iter().map(|i| Ident { name: *i, span: DUMMY_SP }))
1232 )
1233 }
1234}
1235
1236#[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)]
1237pub struct AttrItem {
1238 pub path: AttrPath,
1240 pub args: AttrArgs,
1241 pub id: HashIgnoredAttrId,
1242 pub style: AttrStyle,
1245 pub span: Span,
1247}
1248
1249#[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)]
1252pub struct HashIgnoredAttrId {
1253 pub attr_id: AttrId,
1254}
1255
1256#[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)]
1257pub enum Attribute {
1258 Parsed(AttributeKind),
1264
1265 Unparsed(Box<AttrItem>),
1268}
1269
1270impl Attribute {
1271 pub fn get_normal_item(&self) -> &AttrItem {
1272 match &self {
1273 Attribute::Unparsed(normal) => &normal,
1274 _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1275 }
1276 }
1277
1278 pub fn unwrap_normal_item(self) -> AttrItem {
1279 match self {
1280 Attribute::Unparsed(normal) => *normal,
1281 _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1282 }
1283 }
1284
1285 pub fn value_lit(&self) -> Option<&MetaItemLit> {
1286 match &self {
1287 Attribute::Unparsed(n) => match n.as_ref() {
1288 AttrItem { args: AttrArgs::Eq { eq_span: _, expr }, .. } => Some(expr),
1289 _ => None,
1290 },
1291 _ => None,
1292 }
1293 }
1294
1295 pub fn is_parsed_attr(&self) -> bool {
1296 match self {
1297 Attribute::Parsed(_) => true,
1298 Attribute::Unparsed(_) => false,
1299 }
1300 }
1301}
1302
1303impl AttributeExt for Attribute {
1304 #[inline]
1305 fn id(&self) -> AttrId {
1306 match &self {
1307 Attribute::Unparsed(u) => u.id.attr_id,
1308 _ => ::core::panicking::panic("explicit panic")panic!(),
1309 }
1310 }
1311
1312 #[inline]
1313 fn meta_item_list(&self) -> Option<ThinVec<ast::MetaItemInner>> {
1314 match &self {
1315 Attribute::Unparsed(n) => match n.as_ref() {
1316 AttrItem { args: AttrArgs::Delimited(d), .. } => {
1317 ast::MetaItemKind::list_from_tokens(d.tokens.clone())
1318 }
1319 _ => None,
1320 },
1321 _ => None,
1322 }
1323 }
1324
1325 #[inline]
1326 fn value_str(&self) -> Option<Symbol> {
1327 self.value_lit().and_then(|x| x.value_str())
1328 }
1329
1330 #[inline]
1331 fn value_span(&self) -> Option<Span> {
1332 self.value_lit().map(|i| i.span)
1333 }
1334
1335 #[inline]
1337 fn name(&self) -> Option<Symbol> {
1338 match &self {
1339 Attribute::Unparsed(n) => {
1340 if let [ident] = n.path.segments.as_ref() {
1341 Some(*ident)
1342 } else {
1343 None
1344 }
1345 }
1346 _ => None,
1347 }
1348 }
1349
1350 #[inline]
1351 fn path_matches(&self, name: &[Symbol]) -> bool {
1352 match &self {
1353 Attribute::Unparsed(n) => n.path.segments.iter().eq(name),
1354 _ => false,
1355 }
1356 }
1357
1358 #[inline]
1359 fn is_doc_comment(&self) -> Option<Span> {
1360 if let Attribute::Parsed(AttributeKind::DocComment { span, .. }) = self {
1361 Some(*span)
1362 } else {
1363 None
1364 }
1365 }
1366
1367 #[inline]
1368 fn span(&self) -> Span {
1369 match &self {
1370 Attribute::Unparsed(u) => u.span,
1371 Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
1373 Attribute::Parsed(AttributeKind::Deprecation { span, .. }) => *span,
1374 Attribute::Parsed(AttributeKind::CfgTrace(cfgs)) => cfgs[0].1,
1375 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:?}"),
1376 }
1377 }
1378
1379 #[inline]
1380 fn is_word(&self) -> bool {
1381 match &self {
1382 Attribute::Unparsed(n) => {
1383 #[allow(non_exhaustive_omitted_patterns)] match n.args {
AttrArgs::Empty => true,
_ => false,
}matches!(n.args, AttrArgs::Empty)
1384 }
1385 _ => false,
1386 }
1387 }
1388
1389 #[inline]
1390 fn symbol_path(&self) -> Option<SmallVec<[Symbol; 1]>> {
1391 match &self {
1392 Attribute::Unparsed(n) => Some(n.path.segments.iter().copied().collect()),
1393 _ => None,
1394 }
1395 }
1396
1397 fn path_span(&self) -> Option<Span> {
1398 match &self {
1399 Attribute::Unparsed(attr) => Some(attr.path.span),
1400 Attribute::Parsed(_) => None,
1401 }
1402 }
1403
1404 #[inline]
1405 fn doc_str(&self) -> Option<Symbol> {
1406 match &self {
1407 Attribute::Parsed(AttributeKind::DocComment { comment, .. }) => Some(*comment),
1408 _ => None,
1409 }
1410 }
1411
1412 #[inline]
1413 fn deprecation_note(&self) -> Option<Ident> {
1414 match &self {
1415 Attribute::Parsed(AttributeKind::Deprecation { deprecation, .. }) => deprecation.note,
1416 _ => None,
1417 }
1418 }
1419
1420 fn is_automatically_derived_attr(&self) -> bool {
1421 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)) => true,
_ => false,
}matches!(self, Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)))
1422 }
1423
1424 #[inline]
1425 fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1426 match &self {
1427 Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => {
1428 Some((*comment, *kind))
1429 }
1430 _ => None,
1431 }
1432 }
1433
1434 fn doc_resolution_scope(&self) -> Option<AttrStyle> {
1435 match self {
1436 Attribute::Parsed(AttributeKind::DocComment { style, .. }) => Some(*style),
1437 Attribute::Unparsed(attr) if self.has_name(sym::doc) && self.value_str().is_some() => {
1438 Some(attr.style)
1439 }
1440 _ => None,
1441 }
1442 }
1443
1444 fn is_proc_macro_attr(&self) -> bool {
1445 #[allow(non_exhaustive_omitted_patterns)] match self {
Attribute::Parsed(AttributeKind::ProcMacro(..) |
AttributeKind::ProcMacroAttribute(..) |
AttributeKind::ProcMacroDerive { .. }) => true,
_ => false,
}matches!(
1446 self,
1447 Attribute::Parsed(
1448 AttributeKind::ProcMacro(..)
1449 | AttributeKind::ProcMacroAttribute(..)
1450 | AttributeKind::ProcMacroDerive { .. }
1451 )
1452 )
1453 }
1454
1455 fn is_doc_hidden(&self) -> bool {
1456 #[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())
1457 }
1458
1459 fn is_doc_keyword_or_attribute(&self) -> bool {
1460 #[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())
1461 }
1462}
1463
1464impl Attribute {
1466 #[inline]
1467 pub fn id(&self) -> AttrId {
1468 AttributeExt::id(self)
1469 }
1470
1471 #[inline]
1472 pub fn name(&self) -> Option<Symbol> {
1473 AttributeExt::name(self)
1474 }
1475
1476 #[inline]
1477 pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
1478 AttributeExt::meta_item_list(self)
1479 }
1480
1481 #[inline]
1482 pub fn value_str(&self) -> Option<Symbol> {
1483 AttributeExt::value_str(self)
1484 }
1485
1486 #[inline]
1487 pub fn value_span(&self) -> Option<Span> {
1488 AttributeExt::value_span(self)
1489 }
1490
1491 #[inline]
1492 pub fn path_matches(&self, name: &[Symbol]) -> bool {
1493 AttributeExt::path_matches(self, name)
1494 }
1495
1496 #[inline]
1497 pub fn is_doc_comment(&self) -> Option<Span> {
1498 AttributeExt::is_doc_comment(self)
1499 }
1500
1501 #[inline]
1502 pub fn has_name(&self, name: Symbol) -> bool {
1503 AttributeExt::has_name(self, name)
1504 }
1505
1506 #[inline]
1507 pub fn has_any_name(&self, names: &[Symbol]) -> bool {
1508 AttributeExt::has_any_name(self, names)
1509 }
1510
1511 #[inline]
1512 pub fn span(&self) -> Span {
1513 AttributeExt::span(self)
1514 }
1515
1516 #[inline]
1517 pub fn is_word(&self) -> bool {
1518 AttributeExt::is_word(self)
1519 }
1520
1521 #[inline]
1522 pub fn path(&self) -> SmallVec<[Symbol; 1]> {
1523 AttributeExt::path(self)
1524 }
1525
1526 #[inline]
1527 pub fn doc_str(&self) -> Option<Symbol> {
1528 AttributeExt::doc_str(self)
1529 }
1530
1531 #[inline]
1532 pub fn is_proc_macro_attr(&self) -> bool {
1533 AttributeExt::is_proc_macro_attr(self)
1534 }
1535
1536 #[inline]
1537 pub fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1538 AttributeExt::doc_str_and_fragment_kind(self)
1539 }
1540}
1541
1542#[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)]
1544pub struct AttributeMap<'tcx> {
1545 pub map: SortedMap<ItemLocalId, &'tcx [Attribute]>,
1546 pub define_opaque: Option<&'tcx [(Span, LocalDefId)]>,
1548 pub opt_hash: Option<Fingerprint>,
1550}
1551
1552impl<'tcx> AttributeMap<'tcx> {
1553 pub const EMPTY: &'static AttributeMap<'static> = &AttributeMap {
1554 map: SortedMap::new(),
1555 opt_hash: Some(Fingerprint::ZERO),
1556 define_opaque: None,
1557 };
1558
1559 #[inline]
1560 pub fn get(&self, id: ItemLocalId) -> &'tcx [Attribute] {
1561 self.map.get(&id).copied().unwrap_or(&[])
1562 }
1563}
1564
1565pub struct OwnerNodes<'tcx> {
1569 pub opt_hash_including_bodies: Option<Fingerprint>,
1572 pub nodes: IndexVec<ItemLocalId, ParentedNode<'tcx>>,
1577 pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>,
1579}
1580
1581impl<'tcx> OwnerNodes<'tcx> {
1582 pub fn node(&self) -> OwnerNode<'tcx> {
1583 self.nodes[ItemLocalId::ZERO].node.as_owner().unwrap()
1585 }
1586}
1587
1588impl fmt::Debug for OwnerNodes<'_> {
1589 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1590 f.debug_struct("OwnerNodes")
1591 .field("node", &self.nodes[ItemLocalId::ZERO])
1593 .field(
1594 "parents",
1595 &fmt::from_fn(|f| {
1596 f.debug_list()
1597 .entries(self.nodes.iter_enumerated().map(|(id, parented_node)| {
1598 fmt::from_fn(move |f| f.write_fmt(format_args!("({1:?}, {0:?})", parented_node.parent, id))write!(f, "({id:?}, {:?})", parented_node.parent))
1599 }))
1600 .finish()
1601 }),
1602 )
1603 .field("bodies", &self.bodies)
1604 .field("opt_hash_including_bodies", &self.opt_hash_including_bodies)
1605 .finish()
1606 }
1607}
1608
1609#[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)]
1611pub struct OwnerInfo<'hir> {
1612 pub nodes: OwnerNodes<'hir>,
1614 pub parenting: LocalDefIdMap<ItemLocalId>,
1616 pub attrs: AttributeMap<'hir>,
1618 pub trait_map: ItemLocalMap<Box<[TraitCandidate]>>,
1621
1622 pub delayed_lints: DelayedLints,
1625}
1626
1627impl<'tcx> OwnerInfo<'tcx> {
1628 #[inline]
1629 pub fn node(&self) -> OwnerNode<'tcx> {
1630 self.nodes.node()
1631 }
1632}
1633
1634#[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)]
1635pub enum MaybeOwner<'tcx> {
1636 Owner(&'tcx OwnerInfo<'tcx>),
1637 NonOwner(HirId),
1638 Phantom,
1640}
1641
1642impl<'tcx> MaybeOwner<'tcx> {
1643 pub fn as_owner(self) -> Option<&'tcx OwnerInfo<'tcx>> {
1644 match self {
1645 MaybeOwner::Owner(i) => Some(i),
1646 MaybeOwner::NonOwner(_) | MaybeOwner::Phantom => None,
1647 }
1648 }
1649
1650 pub fn unwrap(self) -> &'tcx OwnerInfo<'tcx> {
1651 self.as_owner().unwrap_or_else(|| { ::core::panicking::panic_fmt(format_args!("Not a HIR owner")); }panic!("Not a HIR owner"))
1652 }
1653}
1654
1655#[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)]
1662pub struct Crate<'hir> {
1663 pub owners: IndexVec<LocalDefId, MaybeOwner<'hir>>,
1664 pub opt_hir_hash: Option<Fingerprint>,
1666}
1667
1668#[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)]
1669pub struct Closure<'hir> {
1670 pub def_id: LocalDefId,
1671 pub binder: ClosureBinder,
1672 pub constness: Constness,
1673 pub capture_clause: CaptureBy,
1674 pub bound_generic_params: &'hir [GenericParam<'hir>],
1675 pub fn_decl: &'hir FnDecl<'hir>,
1676 pub body: BodyId,
1677 pub fn_decl_span: Span,
1679 pub fn_arg_span: Option<Span>,
1681 pub kind: ClosureKind,
1682}
1683
1684#[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)]
1685pub enum ClosureKind {
1686 Closure,
1688 Coroutine(CoroutineKind),
1693 CoroutineClosure(CoroutineDesugaring),
1698}
1699
1700#[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)]
1704pub struct Block<'hir> {
1705 pub stmts: &'hir [Stmt<'hir>],
1707 pub expr: Option<&'hir Expr<'hir>>,
1710 #[stable_hasher(ignore)]
1711 pub hir_id: HirId,
1712 pub rules: BlockCheckMode,
1714 pub span: Span,
1716 pub targeted_by_break: bool,
1720}
1721
1722impl<'hir> Block<'hir> {
1723 pub fn innermost_block(&self) -> &Block<'hir> {
1724 let mut block = self;
1725 while let Some(Expr { kind: ExprKind::Block(inner_block, _), .. }) = block.expr {
1726 block = inner_block;
1727 }
1728 block
1729 }
1730}
1731
1732#[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)]
1733pub struct TyPat<'hir> {
1734 #[stable_hasher(ignore)]
1735 pub hir_id: HirId,
1736 pub kind: TyPatKind<'hir>,
1737 pub span: Span,
1738}
1739
1740#[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)]
1741pub struct Pat<'hir> {
1742 #[stable_hasher(ignore)]
1743 pub hir_id: HirId,
1744 pub kind: PatKind<'hir>,
1745 pub span: Span,
1746 pub default_binding_modes: bool,
1749}
1750
1751impl<'hir> Pat<'hir> {
1752 fn walk_short_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) -> bool {
1753 if !it(self) {
1754 return false;
1755 }
1756
1757 use PatKind::*;
1758 match self.kind {
1759 Missing => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1760 Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => true,
1761 Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => {
1762 s.walk_short_(it)
1763 }
1764 Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
1765 TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().all(|p| p.walk_short_(it)),
1766 Slice(before, slice, after) => {
1767 before.iter().chain(slice).chain(after.iter()).all(|p| p.walk_short_(it))
1768 }
1769 }
1770 }
1771
1772 pub fn walk_short(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) -> bool {
1779 self.walk_short_(&mut it)
1780 }
1781
1782 fn walk_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) {
1783 if !it(self) {
1784 return;
1785 }
1786
1787 use PatKind::*;
1788 match self.kind {
1789 Missing | Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => {}
1790 Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_(it),
1791 Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
1792 TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
1793 Slice(before, slice, after) => {
1794 before.iter().chain(slice).chain(after.iter()).for_each(|p| p.walk_(it))
1795 }
1796 }
1797 }
1798
1799 pub fn walk(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) {
1803 self.walk_(&mut it)
1804 }
1805
1806 pub fn walk_always(&self, mut it: impl FnMut(&Pat<'_>)) {
1810 self.walk(|p| {
1811 it(p);
1812 true
1813 })
1814 }
1815
1816 pub fn is_never_pattern(&self) -> bool {
1818 let mut is_never_pattern = false;
1819 self.walk(|pat| match &pat.kind {
1820 PatKind::Never => {
1821 is_never_pattern = true;
1822 false
1823 }
1824 PatKind::Or(s) => {
1825 is_never_pattern = s.iter().all(|p| p.is_never_pattern());
1826 false
1827 }
1828 _ => true,
1829 });
1830 is_never_pattern
1831 }
1832
1833 pub fn is_guaranteed_to_constitute_read_for_never(&self) -> bool {
1842 match self.kind {
1843 PatKind::Wild => false,
1845
1846 PatKind::Guard(pat, _) => pat.is_guaranteed_to_constitute_read_for_never(),
1849
1850 PatKind::Or(subpats) => {
1859 subpats.iter().all(|pat| pat.is_guaranteed_to_constitute_read_for_never())
1860 }
1861
1862 PatKind::Never => true,
1864
1865 PatKind::Missing
1868 | PatKind::Binding(_, _, _, _)
1869 | PatKind::Struct(_, _, _)
1870 | PatKind::TupleStruct(_, _, _)
1871 | PatKind::Tuple(_, _)
1872 | PatKind::Box(_)
1873 | PatKind::Ref(_, _, _)
1874 | PatKind::Deref(_)
1875 | PatKind::Expr(_)
1876 | PatKind::Range(_, _, _)
1877 | PatKind::Slice(_, _, _)
1878 | PatKind::Err(_) => true,
1879 }
1880 }
1881}
1882
1883#[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)]
1889pub struct PatField<'hir> {
1890 #[stable_hasher(ignore)]
1891 pub hir_id: HirId,
1892 pub ident: Ident,
1894 pub pat: &'hir Pat<'hir>,
1896 pub is_shorthand: bool,
1897 pub span: Span,
1898}
1899
1900#[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)]
1901pub enum RangeEnd {
1902 Included,
1903 Excluded,
1904}
1905
1906impl fmt::Display for RangeEnd {
1907 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1908 f.write_str(match self {
1909 RangeEnd::Included => "..=",
1910 RangeEnd::Excluded => "..",
1911 })
1912 }
1913}
1914
1915#[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)]
1919pub struct DotDotPos(u32);
1920
1921impl DotDotPos {
1922 pub fn new(n: Option<usize>) -> Self {
1924 match n {
1925 Some(n) => {
1926 if !(n < u32::MAX as usize) {
::core::panicking::panic("assertion failed: n < u32::MAX as usize")
};assert!(n < u32::MAX as usize);
1927 Self(n as u32)
1928 }
1929 None => Self(u32::MAX),
1930 }
1931 }
1932
1933 pub fn as_opt_usize(&self) -> Option<usize> {
1934 if self.0 == u32::MAX { None } else { Some(self.0 as usize) }
1935 }
1936}
1937
1938impl fmt::Debug for DotDotPos {
1939 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1940 self.as_opt_usize().fmt(f)
1941 }
1942}
1943
1944#[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)]
1945pub struct PatExpr<'hir> {
1946 #[stable_hasher(ignore)]
1947 pub hir_id: HirId,
1948 pub span: Span,
1949 pub kind: PatExprKind<'hir>,
1950}
1951
1952#[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)]
1953pub enum PatExprKind<'hir> {
1954 Lit {
1955 lit: Lit,
1956 negated: bool,
1959 },
1960 Path(QPath<'hir>),
1962}
1963
1964#[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)]
1965pub enum TyPatKind<'hir> {
1966 Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>),
1968
1969 NotNull,
1971
1972 Or(&'hir [TyPat<'hir>]),
1974
1975 Err(ErrorGuaranteed),
1977}
1978
1979#[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)]
1980pub enum PatKind<'hir> {
1981 Missing,
1983
1984 Wild,
1986
1987 Binding(BindingMode, HirId, Ident, Option<&'hir Pat<'hir>>),
1998
1999 Struct(QPath<'hir>, &'hir [PatField<'hir>], Option<Span>),
2002
2003 TupleStruct(QPath<'hir>, &'hir [Pat<'hir>], DotDotPos),
2007
2008 Or(&'hir [Pat<'hir>]),
2011
2012 Never,
2014
2015 Tuple(&'hir [Pat<'hir>], DotDotPos),
2019
2020 Box(&'hir Pat<'hir>),
2022
2023 Deref(&'hir Pat<'hir>),
2025
2026 Ref(&'hir Pat<'hir>, Pinnedness, Mutability),
2028
2029 Expr(&'hir PatExpr<'hir>),
2031
2032 Guard(&'hir Pat<'hir>, &'hir Expr<'hir>),
2034
2035 Range(Option<&'hir PatExpr<'hir>>, Option<&'hir PatExpr<'hir>>, RangeEnd),
2037
2038 Slice(&'hir [Pat<'hir>], Option<&'hir Pat<'hir>>, &'hir [Pat<'hir>]),
2048
2049 Err(ErrorGuaranteed),
2051}
2052
2053#[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)]
2055pub struct Stmt<'hir> {
2056 #[stable_hasher(ignore)]
2057 pub hir_id: HirId,
2058 pub kind: StmtKind<'hir>,
2059 pub span: Span,
2060}
2061
2062#[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)]
2064pub enum StmtKind<'hir> {
2065 Let(&'hir LetStmt<'hir>),
2067
2068 Item(ItemId),
2070
2071 Expr(&'hir Expr<'hir>),
2073
2074 Semi(&'hir Expr<'hir>),
2076}
2077
2078#[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)]
2080pub struct LetStmt<'hir> {
2081 pub super_: Option<Span>,
2083 pub pat: &'hir Pat<'hir>,
2084 pub ty: Option<&'hir Ty<'hir>>,
2086 pub init: Option<&'hir Expr<'hir>>,
2088 pub els: Option<&'hir Block<'hir>>,
2090 #[stable_hasher(ignore)]
2091 pub hir_id: HirId,
2092 pub span: Span,
2093 pub source: LocalSource,
2097}
2098
2099#[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)]
2102pub struct Arm<'hir> {
2103 #[stable_hasher(ignore)]
2104 pub hir_id: HirId,
2105 pub span: Span,
2106 pub pat: &'hir Pat<'hir>,
2108 pub guard: Option<&'hir Expr<'hir>>,
2110 pub body: &'hir Expr<'hir>,
2112}
2113
2114#[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)]
2120pub struct LetExpr<'hir> {
2121 pub span: Span,
2122 pub pat: &'hir Pat<'hir>,
2123 pub ty: Option<&'hir Ty<'hir>>,
2124 pub init: &'hir Expr<'hir>,
2125 pub recovered: ast::Recovered,
2128}
2129
2130#[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)]
2131pub struct ExprField<'hir> {
2132 #[stable_hasher(ignore)]
2133 pub hir_id: HirId,
2134 pub ident: Ident,
2135 pub expr: &'hir Expr<'hir>,
2136 pub span: Span,
2137 pub is_shorthand: bool,
2138}
2139
2140#[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)]
2141pub enum BlockCheckMode {
2142 DefaultBlock,
2143 UnsafeBlock(UnsafeSource),
2144}
2145
2146#[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)]
2147pub enum UnsafeSource {
2148 CompilerGenerated,
2149 UserProvided,
2150}
2151
2152#[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)]
2153pub struct BodyId {
2154 pub hir_id: HirId,
2155}
2156
2157#[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)]
2179pub struct Body<'hir> {
2180 pub params: &'hir [Param<'hir>],
2181 pub value: &'hir Expr<'hir>,
2182}
2183
2184impl<'hir> Body<'hir> {
2185 pub fn id(&self) -> BodyId {
2186 BodyId { hir_id: self.value.hir_id }
2187 }
2188}
2189
2190#[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)]
2192pub enum CoroutineKind {
2193 Desugared(CoroutineDesugaring, CoroutineSource),
2195
2196 Coroutine(Movability),
2198}
2199
2200impl CoroutineKind {
2201 pub fn movability(self) -> Movability {
2202 match self {
2203 CoroutineKind::Desugared(CoroutineDesugaring::Async, _)
2204 | CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _) => Movability::Static,
2205 CoroutineKind::Desugared(CoroutineDesugaring::Gen, _) => Movability::Movable,
2206 CoroutineKind::Coroutine(mov) => mov,
2207 }
2208 }
2209
2210 pub fn is_fn_like(self) -> bool {
2211 #[allow(non_exhaustive_omitted_patterns)] match self {
CoroutineKind::Desugared(_, CoroutineSource::Fn) => true,
_ => false,
}matches!(self, CoroutineKind::Desugared(_, CoroutineSource::Fn))
2212 }
2213
2214 pub fn to_plural_string(&self) -> String {
2215 match self {
2216 CoroutineKind::Desugared(d, CoroutineSource::Fn) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}fn bodies", d))
})format!("{d:#}fn bodies"),
2217 CoroutineKind::Desugared(d, CoroutineSource::Block) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}blocks", d))
})format!("{d:#}blocks"),
2218 CoroutineKind::Desugared(d, CoroutineSource::Closure) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#}closure bodies", d))
})format!("{d:#}closure bodies"),
2219 CoroutineKind::Coroutine(_) => "coroutines".to_string(),
2220 }
2221 }
2222}
2223
2224impl fmt::Display for CoroutineKind {
2225 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2226 match self {
2227 CoroutineKind::Desugared(d, k) => {
2228 d.fmt(f)?;
2229 k.fmt(f)
2230 }
2231 CoroutineKind::Coroutine(_) => f.write_str("coroutine"),
2232 }
2233 }
2234}
2235
2236#[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)]
2242pub enum CoroutineSource {
2243 Block,
2245
2246 Closure,
2248
2249 Fn,
2251}
2252
2253impl fmt::Display for CoroutineSource {
2254 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2255 match self {
2256 CoroutineSource::Block => "block",
2257 CoroutineSource::Closure => "closure body",
2258 CoroutineSource::Fn => "fn body",
2259 }
2260 .fmt(f)
2261 }
2262}
2263
2264#[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)]
2265pub enum CoroutineDesugaring {
2266 Async,
2268
2269 Gen,
2271
2272 AsyncGen,
2275}
2276
2277impl fmt::Display for CoroutineDesugaring {
2278 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2279 match self {
2280 CoroutineDesugaring::Async => {
2281 if f.alternate() {
2282 f.write_str("`async` ")?;
2283 } else {
2284 f.write_str("async ")?
2285 }
2286 }
2287 CoroutineDesugaring::Gen => {
2288 if f.alternate() {
2289 f.write_str("`gen` ")?;
2290 } else {
2291 f.write_str("gen ")?
2292 }
2293 }
2294 CoroutineDesugaring::AsyncGen => {
2295 if f.alternate() {
2296 f.write_str("`async gen` ")?;
2297 } else {
2298 f.write_str("async gen ")?
2299 }
2300 }
2301 }
2302
2303 Ok(())
2304 }
2305}
2306
2307#[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)]
2308pub enum BodyOwnerKind {
2309 Fn,
2311
2312 Closure,
2314
2315 Const { inline: bool },
2317
2318 Static(Mutability),
2320
2321 GlobalAsm,
2323}
2324
2325impl BodyOwnerKind {
2326 pub fn is_fn_or_closure(self) -> bool {
2327 match self {
2328 BodyOwnerKind::Fn | BodyOwnerKind::Closure => true,
2329 BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(_) | BodyOwnerKind::GlobalAsm => {
2330 false
2331 }
2332 }
2333 }
2334}
2335
2336#[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)]
2338pub enum ConstContext {
2339 ConstFn,
2341
2342 Static(Mutability),
2344
2345 Const { inline: bool },
2355}
2356
2357impl ConstContext {
2358 pub fn keyword_name(self) -> &'static str {
2362 match self {
2363 Self::Const { .. } => "const",
2364 Self::Static(Mutability::Not) => "static",
2365 Self::Static(Mutability::Mut) => "static mut",
2366 Self::ConstFn => "const fn",
2367 }
2368 }
2369}
2370
2371impl fmt::Display for ConstContext {
2374 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2375 match *self {
2376 Self::Const { .. } => f.write_fmt(format_args!("constant"))write!(f, "constant"),
2377 Self::Static(_) => f.write_fmt(format_args!("static"))write!(f, "static"),
2378 Self::ConstFn => f.write_fmt(format_args!("constant function"))write!(f, "constant function"),
2379 }
2380 }
2381}
2382
2383impl IntoDiagArg for ConstContext {
2384 fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
2385 DiagArgValue::Str(Cow::Borrowed(match self {
2386 ConstContext::ConstFn => "const_fn",
2387 ConstContext::Static(_) => "static",
2388 ConstContext::Const { .. } => "const",
2389 }))
2390 }
2391}
2392
2393pub type Lit = Spanned<LitKind>;
2395
2396#[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)]
2405pub struct AnonConst {
2406 #[stable_hasher(ignore)]
2407 pub hir_id: HirId,
2408 pub def_id: LocalDefId,
2409 pub body: BodyId,
2410 pub span: Span,
2411}
2412
2413#[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)]
2415pub struct ConstBlock {
2416 #[stable_hasher(ignore)]
2417 pub hir_id: HirId,
2418 pub def_id: LocalDefId,
2419 pub body: BodyId,
2420}
2421
2422#[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)]
2431pub struct Expr<'hir> {
2432 #[stable_hasher(ignore)]
2433 pub hir_id: HirId,
2434 pub kind: ExprKind<'hir>,
2435 pub span: Span,
2436}
2437
2438impl Expr<'_> {
2439 pub fn precedence(&self, has_attr: &dyn Fn(HirId) -> bool) -> ExprPrecedence {
2440 let prefix_attrs_precedence = || -> ExprPrecedence {
2441 if has_attr(self.hir_id) { ExprPrecedence::Prefix } else { ExprPrecedence::Unambiguous }
2442 };
2443
2444 match &self.kind {
2445 ExprKind::Closure(closure) => {
2446 match closure.fn_decl.output {
2447 FnRetTy::DefaultReturn(_) => ExprPrecedence::Jump,
2448 FnRetTy::Return(_) => prefix_attrs_precedence(),
2449 }
2450 }
2451
2452 ExprKind::Break(..)
2453 | ExprKind::Ret(..)
2454 | ExprKind::Yield(..)
2455 | ExprKind::Become(..) => ExprPrecedence::Jump,
2456
2457 ExprKind::Binary(op, ..) => op.node.precedence(),
2459 ExprKind::Cast(..) => ExprPrecedence::Cast,
2460
2461 ExprKind::Assign(..) |
2462 ExprKind::AssignOp(..) => ExprPrecedence::Assign,
2463
2464 ExprKind::AddrOf(..)
2466 | ExprKind::Let(..)
2471 | ExprKind::Unary(..) => ExprPrecedence::Prefix,
2472
2473 ExprKind::Array(_)
2475 | ExprKind::Block(..)
2476 | ExprKind::Call(..)
2477 | ExprKind::ConstBlock(_)
2478 | ExprKind::Continue(..)
2479 | ExprKind::Field(..)
2480 | ExprKind::If(..)
2481 | ExprKind::Index(..)
2482 | ExprKind::InlineAsm(..)
2483 | ExprKind::Lit(_)
2484 | ExprKind::Loop(..)
2485 | ExprKind::Match(..)
2486 | ExprKind::MethodCall(..)
2487 | ExprKind::OffsetOf(..)
2488 | ExprKind::Path(..)
2489 | ExprKind::Repeat(..)
2490 | ExprKind::Struct(..)
2491 | ExprKind::Tup(_)
2492 | ExprKind::Type(..)
2493 | ExprKind::UnsafeBinderCast(..)
2494 | ExprKind::Use(..)
2495 | ExprKind::Err(_) => prefix_attrs_precedence(),
2496
2497 ExprKind::DropTemps(expr, ..) => expr.precedence(has_attr),
2498 }
2499 }
2500
2501 pub fn is_syntactic_place_expr(&self) -> bool {
2506 self.is_place_expr(|_| true)
2507 }
2508
2509 pub fn is_place_expr(&self, mut allow_projections_from: impl FnMut(&Self) -> bool) -> bool {
2514 match self.kind {
2515 ExprKind::Path(QPath::Resolved(_, ref path)) => {
2516 #[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)
2517 }
2518
2519 ExprKind::Type(ref e, _) => e.is_place_expr(allow_projections_from),
2523
2524 ExprKind::UnsafeBinderCast(_, e, _) => e.is_place_expr(allow_projections_from),
2526
2527 ExprKind::Unary(UnOp::Deref, _) => true,
2528
2529 ExprKind::Field(ref base, _) | ExprKind::Index(ref base, _, _) => {
2530 allow_projections_from(base) || base.is_place_expr(allow_projections_from)
2531 }
2532
2533 ExprKind::Err(_guar)
2535 | ExprKind::Let(&LetExpr { recovered: ast::Recovered::Yes(_guar), .. }) => true,
2536
2537 ExprKind::Path(QPath::TypeRelative(..))
2540 | ExprKind::Call(..)
2541 | ExprKind::MethodCall(..)
2542 | ExprKind::Use(..)
2543 | ExprKind::Struct(..)
2544 | ExprKind::Tup(..)
2545 | ExprKind::If(..)
2546 | ExprKind::Match(..)
2547 | ExprKind::Closure { .. }
2548 | ExprKind::Block(..)
2549 | ExprKind::Repeat(..)
2550 | ExprKind::Array(..)
2551 | ExprKind::Break(..)
2552 | ExprKind::Continue(..)
2553 | ExprKind::Ret(..)
2554 | ExprKind::Become(..)
2555 | ExprKind::Let(..)
2556 | ExprKind::Loop(..)
2557 | ExprKind::Assign(..)
2558 | ExprKind::InlineAsm(..)
2559 | ExprKind::OffsetOf(..)
2560 | ExprKind::AssignOp(..)
2561 | ExprKind::Lit(_)
2562 | ExprKind::ConstBlock(..)
2563 | ExprKind::Unary(..)
2564 | ExprKind::AddrOf(..)
2565 | ExprKind::Binary(..)
2566 | ExprKind::Yield(..)
2567 | ExprKind::Cast(..)
2568 | ExprKind::DropTemps(..) => false,
2569 }
2570 }
2571
2572 pub fn range_span(&self) -> Option<Span> {
2575 is_range_literal(self).then(|| self.span.parent_callsite().unwrap())
2576 }
2577
2578 pub fn is_size_lit(&self) -> bool {
2581 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ExprKind::Lit(Lit {
node: LitKind::Int(_,
LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)), ..
}) => true,
_ => false,
}matches!(
2582 self.kind,
2583 ExprKind::Lit(Lit {
2584 node: LitKind::Int(_, LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)),
2585 ..
2586 })
2587 )
2588 }
2589
2590 pub fn peel_drop_temps(&self) -> &Self {
2596 let mut expr = self;
2597 while let ExprKind::DropTemps(inner) = &expr.kind {
2598 expr = inner;
2599 }
2600 expr
2601 }
2602
2603 pub fn peel_blocks(&self) -> &Self {
2604 let mut expr = self;
2605 while let ExprKind::Block(Block { expr: Some(inner), .. }, _) = &expr.kind {
2606 expr = inner;
2607 }
2608 expr
2609 }
2610
2611 pub fn peel_borrows(&self) -> &Self {
2612 let mut expr = self;
2613 while let ExprKind::AddrOf(.., inner) = &expr.kind {
2614 expr = inner;
2615 }
2616 expr
2617 }
2618
2619 pub fn can_have_side_effects(&self) -> bool {
2620 match self.peel_drop_temps().kind {
2621 ExprKind::Path(_) | ExprKind::Lit(_) | ExprKind::OffsetOf(..) | ExprKind::Use(..) => {
2622 false
2623 }
2624 ExprKind::Type(base, _)
2625 | ExprKind::Unary(_, base)
2626 | ExprKind::Field(base, _)
2627 | ExprKind::Index(base, _, _)
2628 | ExprKind::AddrOf(.., base)
2629 | ExprKind::Cast(base, _)
2630 | ExprKind::UnsafeBinderCast(_, base, _) => {
2631 base.can_have_side_effects()
2635 }
2636 ExprKind::Binary(_, lhs, rhs) => {
2637 lhs.can_have_side_effects() || rhs.can_have_side_effects()
2641 }
2642 ExprKind::Struct(_, fields, init) => {
2643 let init_side_effects = match init {
2644 StructTailExpr::Base(init) => init.can_have_side_effects(),
2645 StructTailExpr::DefaultFields(_) | StructTailExpr::None => false,
2646 };
2647 fields.iter().map(|field| field.expr).any(|e| e.can_have_side_effects())
2648 || init_side_effects
2649 }
2650
2651 ExprKind::Array(args)
2652 | ExprKind::Tup(args)
2653 | ExprKind::Call(
2654 Expr {
2655 kind:
2656 ExprKind::Path(QPath::Resolved(
2657 None,
2658 Path { res: Res::Def(DefKind::Ctor(_, CtorKind::Fn), _), .. },
2659 )),
2660 ..
2661 },
2662 args,
2663 ) => args.iter().any(|arg| arg.can_have_side_effects()),
2664 ExprKind::Repeat(arg, _) => arg.can_have_side_effects(),
2665 ExprKind::If(..)
2666 | ExprKind::Match(..)
2667 | ExprKind::MethodCall(..)
2668 | ExprKind::Call(..)
2669 | ExprKind::Closure { .. }
2670 | ExprKind::Block(..)
2671 | ExprKind::Break(..)
2672 | ExprKind::Continue(..)
2673 | ExprKind::Ret(..)
2674 | ExprKind::Become(..)
2675 | ExprKind::Let(..)
2676 | ExprKind::Loop(..)
2677 | ExprKind::Assign(..)
2678 | ExprKind::InlineAsm(..)
2679 | ExprKind::AssignOp(..)
2680 | ExprKind::ConstBlock(..)
2681 | ExprKind::Yield(..)
2682 | ExprKind::DropTemps(..)
2683 | ExprKind::Err(_) => true,
2684 }
2685 }
2686
2687 pub fn is_approximately_pattern(&self) -> bool {
2689 match &self.kind {
2690 ExprKind::Array(_)
2691 | ExprKind::Call(..)
2692 | ExprKind::Tup(_)
2693 | ExprKind::Lit(_)
2694 | ExprKind::Path(_)
2695 | ExprKind::Struct(..) => true,
2696 _ => false,
2697 }
2698 }
2699
2700 pub fn equivalent_for_indexing(&self, other: &Expr<'_>) -> bool {
2705 match (self.kind, other.kind) {
2706 (ExprKind::Lit(lit1), ExprKind::Lit(lit2)) => lit1.node == lit2.node,
2707 (
2708 ExprKind::Path(QPath::Resolved(None, path1)),
2709 ExprKind::Path(QPath::Resolved(None, path2)),
2710 ) => path1.res == path2.res,
2711 (
2712 ExprKind::Struct(
2713 &QPath::Resolved(None, &Path { res: Res::Def(_, path1_def_id), .. }),
2714 args1,
2715 StructTailExpr::None,
2716 ),
2717 ExprKind::Struct(
2718 &QPath::Resolved(None, &Path { res: Res::Def(_, path2_def_id), .. }),
2719 args2,
2720 StructTailExpr::None,
2721 ),
2722 ) => {
2723 path2_def_id == path1_def_id
2724 && is_range_literal(self)
2725 && is_range_literal(other)
2726 && std::iter::zip(args1, args2)
2727 .all(|(a, b)| a.expr.equivalent_for_indexing(b.expr))
2728 }
2729 _ => false,
2730 }
2731 }
2732
2733 pub fn method_ident(&self) -> Option<Ident> {
2734 match self.kind {
2735 ExprKind::MethodCall(receiver_method, ..) => Some(receiver_method.ident),
2736 ExprKind::Unary(_, expr) | ExprKind::AddrOf(.., expr) => expr.method_ident(),
2737 _ => None,
2738 }
2739 }
2740}
2741
2742pub fn is_range_literal(expr: &Expr<'_>) -> bool {
2745 if let ExprKind::Struct(QPath::Resolved(None, path), _, StructTailExpr::None) = expr.kind
2746 && let [.., segment] = path.segments
2747 && let sym::RangeFrom
2748 | sym::RangeFull
2749 | sym::Range
2750 | sym::RangeToInclusive
2751 | sym::RangeTo
2752 | sym::RangeFromCopy
2753 | sym::RangeCopy
2754 | sym::RangeInclusiveCopy
2755 | sym::RangeToInclusiveCopy = segment.ident.name
2756 && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2757 {
2758 true
2759 } else if let ExprKind::Call(func, _) = &expr.kind
2760 && let ExprKind::Path(QPath::Resolved(None, path)) = func.kind
2761 && let [.., segment] = path.segments
2762 && let sym::range_inclusive_new = segment.ident.name
2763 && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2764 {
2765 true
2766 } else {
2767 false
2768 }
2769}
2770
2771pub fn expr_needs_parens(expr: &Expr<'_>) -> bool {
2778 match expr.kind {
2779 ExprKind::Cast(_, _) | ExprKind::Binary(_, _, _) => true,
2781 _ if is_range_literal(expr) => true,
2783 _ => false,
2784 }
2785}
2786
2787#[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)]
2788pub enum ExprKind<'hir> {
2789 ConstBlock(ConstBlock),
2791 Array(&'hir [Expr<'hir>]),
2793 Call(&'hir Expr<'hir>, &'hir [Expr<'hir>]),
2800 MethodCall(&'hir PathSegment<'hir>, &'hir Expr<'hir>, &'hir [Expr<'hir>], Span),
2817 Use(&'hir Expr<'hir>, Span),
2819 Tup(&'hir [Expr<'hir>]),
2821 Binary(BinOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2823 Unary(UnOp, &'hir Expr<'hir>),
2825 Lit(Lit),
2827 Cast(&'hir Expr<'hir>, &'hir Ty<'hir>),
2829 Type(&'hir Expr<'hir>, &'hir Ty<'hir>),
2831 DropTemps(&'hir Expr<'hir>),
2837 Let(&'hir LetExpr<'hir>),
2842 If(&'hir Expr<'hir>, &'hir Expr<'hir>, Option<&'hir Expr<'hir>>),
2851 Loop(&'hir Block<'hir>, Option<Label>, LoopSource, Span),
2857 Match(&'hir Expr<'hir>, &'hir [Arm<'hir>], MatchSource),
2860 Closure(&'hir Closure<'hir>),
2867 Block(&'hir Block<'hir>, Option<Label>),
2869
2870 Assign(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
2872 AssignOp(AssignOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2876 Field(&'hir Expr<'hir>, Ident),
2878 Index(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
2882
2883 Path(QPath<'hir>),
2885
2886 AddrOf(BorrowKind, Mutability, &'hir Expr<'hir>),
2888 Break(Destination, Option<&'hir Expr<'hir>>),
2890 Continue(Destination),
2892 Ret(Option<&'hir Expr<'hir>>),
2894 Become(&'hir Expr<'hir>),
2896
2897 InlineAsm(&'hir InlineAsm<'hir>),
2899
2900 OffsetOf(&'hir Ty<'hir>, &'hir [Ident]),
2902
2903 Struct(&'hir QPath<'hir>, &'hir [ExprField<'hir>], StructTailExpr<'hir>),
2908
2909 Repeat(&'hir Expr<'hir>, &'hir ConstArg<'hir>),
2914
2915 Yield(&'hir Expr<'hir>, YieldSource),
2917
2918 UnsafeBinderCast(UnsafeBinderCastKind, &'hir Expr<'hir>, Option<&'hir Ty<'hir>>),
2921
2922 Err(rustc_span::ErrorGuaranteed),
2924}
2925
2926#[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)]
2927pub enum StructTailExpr<'hir> {
2928 None,
2930 Base(&'hir Expr<'hir>),
2933 DefaultFields(Span),
2937}
2938
2939#[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)]
2945pub enum QPath<'hir> {
2946 Resolved(Option<&'hir Ty<'hir>>, &'hir Path<'hir>),
2953
2954 TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
2961}
2962
2963impl<'hir> QPath<'hir> {
2964 pub fn span(&self) -> Span {
2966 match *self {
2967 QPath::Resolved(_, path) => path.span,
2968 QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
2969 }
2970 }
2971
2972 pub fn qself_span(&self) -> Span {
2975 match *self {
2976 QPath::Resolved(_, path) => path.span,
2977 QPath::TypeRelative(qself, _) => qself.span,
2978 }
2979 }
2980}
2981
2982#[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)]
2984pub enum LocalSource {
2985 Normal,
2987 AsyncFn,
2998 AwaitDesugar,
3000 AssignDesugar,
3002 Contract,
3004}
3005
3006#[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)]
3008pub enum MatchSource {
3009 Normal,
3011 Postfix,
3013 ForLoopDesugar,
3015 TryDesugar(HirId),
3017 AwaitDesugar,
3019 FormatArgs,
3021}
3022
3023impl MatchSource {
3024 #[inline]
3025 pub const fn name(self) -> &'static str {
3026 use MatchSource::*;
3027 match self {
3028 Normal => "match",
3029 Postfix => ".match",
3030 ForLoopDesugar => "for",
3031 TryDesugar(_) => "?",
3032 AwaitDesugar => ".await",
3033 FormatArgs => "format_args!()",
3034 }
3035 }
3036}
3037
3038#[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)]
3040pub enum LoopSource {
3041 Loop,
3043 While,
3045 ForLoop,
3047}
3048
3049impl LoopSource {
3050 pub fn name(self) -> &'static str {
3051 match self {
3052 LoopSource::Loop => "loop",
3053 LoopSource::While => "while",
3054 LoopSource::ForLoop => "for",
3055 }
3056 }
3057}
3058
3059#[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)]
3060pub enum LoopIdError {
3061 OutsideLoopScope,
3062 UnlabeledCfInWhileCondition,
3063 UnresolvedLabel,
3064}
3065
3066impl fmt::Display for LoopIdError {
3067 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3068 f.write_str(match self {
3069 LoopIdError::OutsideLoopScope => "not inside loop scope",
3070 LoopIdError::UnlabeledCfInWhileCondition => {
3071 "unlabeled control flow (break or continue) in while condition"
3072 }
3073 LoopIdError::UnresolvedLabel => "label not found",
3074 })
3075 }
3076}
3077
3078#[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)]
3079pub struct Destination {
3080 pub label: Option<Label>,
3082
3083 pub target_id: Result<HirId, LoopIdError>,
3086}
3087
3088#[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)]
3090pub enum YieldSource {
3091 Await { expr: Option<HirId> },
3093 Yield,
3095}
3096
3097impl fmt::Display for YieldSource {
3098 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3099 f.write_str(match self {
3100 YieldSource::Await { .. } => "`await`",
3101 YieldSource::Yield => "`yield`",
3102 })
3103 }
3104}
3105
3106#[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)]
3109pub struct MutTy<'hir> {
3110 pub ty: &'hir Ty<'hir>,
3111 pub mutbl: Mutability,
3112}
3113
3114#[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)]
3117pub struct FnSig<'hir> {
3118 pub header: FnHeader,
3119 pub decl: &'hir FnDecl<'hir>,
3120 pub span: Span,
3121}
3122
3123#[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)]
3127pub struct TraitItemId {
3128 pub owner_id: OwnerId,
3129}
3130
3131impl TraitItemId {
3132 #[inline]
3133 pub fn hir_id(&self) -> HirId {
3134 HirId::make_owner(self.owner_id.def_id)
3136 }
3137}
3138
3139#[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)]
3144pub struct TraitItem<'hir> {
3145 pub ident: Ident,
3146 pub owner_id: OwnerId,
3147 pub generics: &'hir Generics<'hir>,
3148 pub kind: TraitItemKind<'hir>,
3149 pub span: Span,
3150 pub defaultness: Defaultness,
3151 pub has_delayed_lints: bool,
3152}
3153
3154macro_rules! expect_methods_self_kind {
3155 ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3156 $(
3157 #[track_caller]
3158 pub fn $name(&self) -> $ret_ty {
3159 let $pat = &self.kind else { expect_failed(stringify!($name), self) };
3160 $ret_val
3161 }
3162 )*
3163 }
3164}
3165
3166macro_rules! expect_methods_self {
3167 ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3168 $(
3169 #[track_caller]
3170 pub fn $name(&self) -> $ret_ty {
3171 let $pat = self else { expect_failed(stringify!($name), self) };
3172 $ret_val
3173 }
3174 )*
3175 }
3176}
3177
3178#[track_caller]
3179fn expect_failed<T: fmt::Debug>(ident: &'static str, found: T) -> ! {
3180 {
::core::panicking::panic_fmt(format_args!("{0}: found {1:?}", ident,
found));
}panic!("{ident}: found {found:?}")
3181}
3182
3183impl<'hir> TraitItem<'hir> {
3184 #[inline]
3185 pub fn hir_id(&self) -> HirId {
3186 HirId::make_owner(self.owner_id.def_id)
3188 }
3189
3190 pub fn trait_item_id(&self) -> TraitItemId {
3191 TraitItemId { owner_id: self.owner_id }
3192 }
3193
3194 self
let TraitItemKind::Type(bounds, ty) =
&self.kind else { expect_failed("expect_type", self) };
(bounds, *ty);expect_methods_self_kind! {
3195 expect_const, (&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>),
3196 TraitItemKind::Const(ty, rhs), (ty, *rhs);
3197
3198 expect_fn, (&FnSig<'hir>, &TraitFn<'hir>),
3199 TraitItemKind::Fn(ty, trfn), (ty, trfn);
3200
3201 expect_type, (GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3202 TraitItemKind::Type(bounds, ty), (bounds, *ty);
3203 }
3204}
3205
3206#[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)]
3208pub enum TraitFn<'hir> {
3209 Required(&'hir [Option<Ident>]),
3211
3212 Provided(BodyId),
3214}
3215
3216#[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)]
3218pub enum TraitItemKind<'hir> {
3219 Const(&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>),
3221 Fn(FnSig<'hir>, TraitFn<'hir>),
3223 Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3226}
3227
3228#[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)]
3232pub struct ImplItemId {
3233 pub owner_id: OwnerId,
3234}
3235
3236impl ImplItemId {
3237 #[inline]
3238 pub fn hir_id(&self) -> HirId {
3239 HirId::make_owner(self.owner_id.def_id)
3241 }
3242}
3243
3244#[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)]
3248pub struct ImplItem<'hir> {
3249 pub ident: Ident,
3250 pub owner_id: OwnerId,
3251 pub generics: &'hir Generics<'hir>,
3252 pub kind: ImplItemKind<'hir>,
3253 pub impl_kind: ImplItemImplKind,
3254 pub span: Span,
3255 pub has_delayed_lints: bool,
3256}
3257
3258#[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)]
3259pub enum ImplItemImplKind {
3260 Inherent {
3261 vis_span: Span,
3262 },
3263 Trait {
3264 defaultness: Defaultness,
3265 trait_item_def_id: Result<DefId, ErrorGuaranteed>,
3267 },
3268}
3269
3270impl<'hir> ImplItem<'hir> {
3271 #[inline]
3272 pub fn hir_id(&self) -> HirId {
3273 HirId::make_owner(self.owner_id.def_id)
3275 }
3276
3277 pub fn impl_item_id(&self) -> ImplItemId {
3278 ImplItemId { owner_id: self.owner_id }
3279 }
3280
3281 pub fn vis_span(&self) -> Option<Span> {
3282 match self.impl_kind {
3283 ImplItemImplKind::Trait { .. } => None,
3284 ImplItemImplKind::Inherent { vis_span, .. } => Some(vis_span),
3285 }
3286 }
3287
3288 self
let ImplItemKind::Type(ty) =
&self.kind else { expect_failed("expect_type", self) };
ty;expect_methods_self_kind! {
3289 expect_const, (&'hir Ty<'hir>, ConstItemRhs<'hir>), ImplItemKind::Const(ty, rhs), (ty, *rhs);
3290 expect_fn, (&FnSig<'hir>, BodyId), ImplItemKind::Fn(ty, body), (ty, *body);
3291 expect_type, &'hir Ty<'hir>, ImplItemKind::Type(ty), ty;
3292 }
3293}
3294
3295#[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)]
3297pub enum ImplItemKind<'hir> {
3298 Const(&'hir Ty<'hir>, ConstItemRhs<'hir>),
3301 Fn(FnSig<'hir>, BodyId),
3303 Type(&'hir Ty<'hir>),
3305}
3306
3307#[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)]
3318pub struct AssocItemConstraint<'hir> {
3319 #[stable_hasher(ignore)]
3320 pub hir_id: HirId,
3321 pub ident: Ident,
3322 pub gen_args: &'hir GenericArgs<'hir>,
3323 pub kind: AssocItemConstraintKind<'hir>,
3324 pub span: Span,
3325}
3326
3327impl<'hir> AssocItemConstraint<'hir> {
3328 pub fn ty(self) -> Option<&'hir Ty<'hir>> {
3330 match self.kind {
3331 AssocItemConstraintKind::Equality { term: Term::Ty(ty) } => Some(ty),
3332 _ => None,
3333 }
3334 }
3335
3336 pub fn ct(self) -> Option<&'hir ConstArg<'hir>> {
3338 match self.kind {
3339 AssocItemConstraintKind::Equality { term: Term::Const(ct) } => Some(ct),
3340 _ => None,
3341 }
3342 }
3343}
3344
3345#[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)]
3346pub enum Term<'hir> {
3347 Ty(&'hir Ty<'hir>),
3348 Const(&'hir ConstArg<'hir>),
3349}
3350
3351impl<'hir> From<&'hir Ty<'hir>> for Term<'hir> {
3352 fn from(ty: &'hir Ty<'hir>) -> Self {
3353 Term::Ty(ty)
3354 }
3355}
3356
3357impl<'hir> From<&'hir ConstArg<'hir>> for Term<'hir> {
3358 fn from(c: &'hir ConstArg<'hir>) -> Self {
3359 Term::Const(c)
3360 }
3361}
3362
3363#[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)]
3365pub enum AssocItemConstraintKind<'hir> {
3366 Equality { term: Term<'hir> },
3373 Bound { bounds: &'hir [GenericBound<'hir>] },
3375}
3376
3377impl<'hir> AssocItemConstraintKind<'hir> {
3378 pub fn descr(&self) -> &'static str {
3379 match self {
3380 AssocItemConstraintKind::Equality { .. } => "binding",
3381 AssocItemConstraintKind::Bound { .. } => "constraint",
3382 }
3383 }
3384}
3385
3386#[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)]
3390pub enum AmbigArg {}
3391
3392#[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)]
3397#[repr(C)]
3398pub struct Ty<'hir, Unambig = ()> {
3399 #[stable_hasher(ignore)]
3400 pub hir_id: HirId,
3401 pub span: Span,
3402 pub kind: TyKind<'hir, Unambig>,
3403}
3404
3405impl<'hir> Ty<'hir, AmbigArg> {
3406 pub fn as_unambig_ty(&self) -> &Ty<'hir> {
3417 let ptr = self as *const Ty<'hir, AmbigArg> as *const Ty<'hir, ()>;
3420 unsafe { &*ptr }
3421 }
3422}
3423
3424impl<'hir> Ty<'hir> {
3425 pub fn try_as_ambig_ty(&self) -> Option<&Ty<'hir, AmbigArg>> {
3431 if let TyKind::Infer(()) = self.kind {
3432 return None;
3433 }
3434
3435 let ptr = self as *const Ty<'hir> as *const Ty<'hir, AmbigArg>;
3439 Some(unsafe { &*ptr })
3440 }
3441}
3442
3443impl<'hir> Ty<'hir, AmbigArg> {
3444 pub fn peel_refs(&self) -> &Ty<'hir> {
3445 let mut final_ty = self.as_unambig_ty();
3446 while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3447 final_ty = ty;
3448 }
3449 final_ty
3450 }
3451}
3452
3453impl<'hir> Ty<'hir> {
3454 pub fn peel_refs(&self) -> &Self {
3455 let mut final_ty = self;
3456 while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3457 final_ty = ty;
3458 }
3459 final_ty
3460 }
3461
3462 pub fn as_generic_param(&self) -> Option<(DefId, Ident)> {
3464 let TyKind::Path(QPath::Resolved(None, path)) = self.kind else {
3465 return None;
3466 };
3467 let [segment] = &path.segments else {
3468 return None;
3469 };
3470 match path.res {
3471 Res::Def(DefKind::TyParam, def_id) | Res::SelfTyParam { trait_: def_id } => {
3472 Some((def_id, segment.ident))
3473 }
3474 _ => None,
3475 }
3476 }
3477
3478 pub fn find_self_aliases(&self) -> Vec<Span> {
3479 use crate::intravisit::Visitor;
3480 struct MyVisitor(Vec<Span>);
3481 impl<'v> Visitor<'v> for MyVisitor {
3482 fn visit_ty(&mut self, t: &'v Ty<'v, AmbigArg>) {
3483 if #[allow(non_exhaustive_omitted_patterns)] match &t.kind {
TyKind::Path(QPath::Resolved(_, Path {
res: crate::def::Res::SelfTyAlias { .. }, .. })) => true,
_ => false,
}matches!(
3484 &t.kind,
3485 TyKind::Path(QPath::Resolved(
3486 _,
3487 Path { res: crate::def::Res::SelfTyAlias { .. }, .. },
3488 ))
3489 ) {
3490 self.0.push(t.span);
3491 return;
3492 }
3493 crate::intravisit::walk_ty(self, t);
3494 }
3495 }
3496
3497 let mut my_visitor = MyVisitor(::alloc::vec::Vec::new()vec![]);
3498 my_visitor.visit_ty_unambig(self);
3499 my_visitor.0
3500 }
3501
3502 pub fn is_suggestable_infer_ty(&self) -> bool {
3505 fn are_suggestable_generic_args(generic_args: &[GenericArg<'_>]) -> bool {
3506 generic_args.iter().any(|arg| match arg {
3507 GenericArg::Type(ty) => ty.as_unambig_ty().is_suggestable_infer_ty(),
3508 GenericArg::Infer(_) => true,
3509 _ => false,
3510 })
3511 }
3512 {
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:3512",
"rustc_hir::hir", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir/src/hir.rs"),
::tracing_core::__macro_support::Option::Some(3512u32),
::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);
3513 match &self.kind {
3514 TyKind::Infer(()) => true,
3515 TyKind::Slice(ty) => ty.is_suggestable_infer_ty(),
3516 TyKind::Array(ty, length) => {
3517 ty.is_suggestable_infer_ty() || #[allow(non_exhaustive_omitted_patterns)] match length.kind {
ConstArgKind::Infer(..) => true,
_ => false,
}matches!(length.kind, ConstArgKind::Infer(..))
3518 }
3519 TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
3520 TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),
3521 TyKind::Path(QPath::TypeRelative(ty, segment)) => {
3522 ty.is_suggestable_infer_ty() || are_suggestable_generic_args(segment.args().args)
3523 }
3524 TyKind::Path(QPath::Resolved(ty_opt, Path { segments, .. })) => {
3525 ty_opt.is_some_and(Self::is_suggestable_infer_ty)
3526 || segments
3527 .iter()
3528 .any(|segment| are_suggestable_generic_args(segment.args().args))
3529 }
3530 _ => false,
3531 }
3532 }
3533}
3534
3535#[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)]
3537pub enum PrimTy {
3538 Int(IntTy),
3539 Uint(UintTy),
3540 Float(FloatTy),
3541 Str,
3542 Bool,
3543 Char,
3544}
3545
3546impl PrimTy {
3547 pub const ALL: [Self; 19] = [
3549 Self::Int(IntTy::I8),
3551 Self::Int(IntTy::I16),
3552 Self::Int(IntTy::I32),
3553 Self::Int(IntTy::I64),
3554 Self::Int(IntTy::I128),
3555 Self::Int(IntTy::Isize),
3556 Self::Uint(UintTy::U8),
3557 Self::Uint(UintTy::U16),
3558 Self::Uint(UintTy::U32),
3559 Self::Uint(UintTy::U64),
3560 Self::Uint(UintTy::U128),
3561 Self::Uint(UintTy::Usize),
3562 Self::Float(FloatTy::F16),
3563 Self::Float(FloatTy::F32),
3564 Self::Float(FloatTy::F64),
3565 Self::Float(FloatTy::F128),
3566 Self::Bool,
3567 Self::Char,
3568 Self::Str,
3569 ];
3570
3571 pub fn name_str(self) -> &'static str {
3575 match self {
3576 PrimTy::Int(i) => i.name_str(),
3577 PrimTy::Uint(u) => u.name_str(),
3578 PrimTy::Float(f) => f.name_str(),
3579 PrimTy::Str => "str",
3580 PrimTy::Bool => "bool",
3581 PrimTy::Char => "char",
3582 }
3583 }
3584
3585 pub fn name(self) -> Symbol {
3586 match self {
3587 PrimTy::Int(i) => i.name(),
3588 PrimTy::Uint(u) => u.name(),
3589 PrimTy::Float(f) => f.name(),
3590 PrimTy::Str => sym::str,
3591 PrimTy::Bool => sym::bool,
3592 PrimTy::Char => sym::char,
3593 }
3594 }
3595
3596 pub fn from_name(name: Symbol) -> Option<Self> {
3599 let ty = match name {
3600 sym::i8 => Self::Int(IntTy::I8),
3602 sym::i16 => Self::Int(IntTy::I16),
3603 sym::i32 => Self::Int(IntTy::I32),
3604 sym::i64 => Self::Int(IntTy::I64),
3605 sym::i128 => Self::Int(IntTy::I128),
3606 sym::isize => Self::Int(IntTy::Isize),
3607 sym::u8 => Self::Uint(UintTy::U8),
3608 sym::u16 => Self::Uint(UintTy::U16),
3609 sym::u32 => Self::Uint(UintTy::U32),
3610 sym::u64 => Self::Uint(UintTy::U64),
3611 sym::u128 => Self::Uint(UintTy::U128),
3612 sym::usize => Self::Uint(UintTy::Usize),
3613 sym::f16 => Self::Float(FloatTy::F16),
3614 sym::f32 => Self::Float(FloatTy::F32),
3615 sym::f64 => Self::Float(FloatTy::F64),
3616 sym::f128 => Self::Float(FloatTy::F128),
3617 sym::bool => Self::Bool,
3618 sym::char => Self::Char,
3619 sym::str => Self::Str,
3620 _ => return None,
3621 };
3622 Some(ty)
3623 }
3624}
3625
3626#[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)]
3627pub struct FnPtrTy<'hir> {
3628 pub safety: Safety,
3629 pub abi: ExternAbi,
3630 pub generic_params: &'hir [GenericParam<'hir>],
3631 pub decl: &'hir FnDecl<'hir>,
3632 pub param_idents: &'hir [Option<Ident>],
3635}
3636
3637#[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)]
3638pub struct UnsafeBinderTy<'hir> {
3639 pub generic_params: &'hir [GenericParam<'hir>],
3640 pub inner_ty: &'hir Ty<'hir>,
3641}
3642
3643#[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)]
3644pub struct OpaqueTy<'hir> {
3645 #[stable_hasher(ignore)]
3646 pub hir_id: HirId,
3647 pub def_id: LocalDefId,
3648 pub bounds: GenericBounds<'hir>,
3649 pub origin: OpaqueTyOrigin<LocalDefId>,
3650 pub span: Span,
3651}
3652
3653#[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)]
3654pub enum PreciseCapturingArgKind<T, U> {
3655 Lifetime(T),
3656 Param(U),
3658}
3659
3660pub type PreciseCapturingArg<'hir> =
3661 PreciseCapturingArgKind<&'hir Lifetime, PreciseCapturingNonLifetimeArg>;
3662
3663impl PreciseCapturingArg<'_> {
3664 pub fn hir_id(self) -> HirId {
3665 match self {
3666 PreciseCapturingArg::Lifetime(lt) => lt.hir_id,
3667 PreciseCapturingArg::Param(param) => param.hir_id,
3668 }
3669 }
3670
3671 pub fn name(self) -> Symbol {
3672 match self {
3673 PreciseCapturingArg::Lifetime(lt) => lt.ident.name,
3674 PreciseCapturingArg::Param(param) => param.ident.name,
3675 }
3676 }
3677}
3678
3679#[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)]
3684pub struct PreciseCapturingNonLifetimeArg {
3685 #[stable_hasher(ignore)]
3686 pub hir_id: HirId,
3687 pub ident: Ident,
3688 pub res: Res,
3689}
3690
3691#[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)]
3692#[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)]
3693pub enum RpitContext {
3694 Trait,
3695 TraitImpl,
3696}
3697
3698#[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)]
3700#[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)]
3701pub enum OpaqueTyOrigin<D> {
3702 FnReturn {
3704 parent: D,
3706 in_trait_or_impl: Option<RpitContext>,
3708 },
3709 AsyncFn {
3711 parent: D,
3713 in_trait_or_impl: Option<RpitContext>,
3715 },
3716 TyAlias {
3718 parent: D,
3720 in_assoc_ty: bool,
3722 },
3723}
3724
3725#[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)]
3726pub enum InferDelegationKind {
3727 Input(usize),
3728 Output,
3729}
3730
3731#[repr(u8, C)]
3737#[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)]
3738pub enum TyKind<'hir, Unambig = ()> {
3739 InferDelegation(DefId, InferDelegationKind),
3741 Slice(&'hir Ty<'hir>),
3743 Array(&'hir Ty<'hir>, &'hir ConstArg<'hir>),
3745 Ptr(MutTy<'hir>),
3747 Ref(&'hir Lifetime, MutTy<'hir>),
3749 FnPtr(&'hir FnPtrTy<'hir>),
3751 UnsafeBinder(&'hir UnsafeBinderTy<'hir>),
3753 Never,
3755 Tup(&'hir [Ty<'hir>]),
3757 Path(QPath<'hir>),
3762 OpaqueDef(&'hir OpaqueTy<'hir>),
3764 TraitAscription(GenericBounds<'hir>),
3766 TraitObject(&'hir [PolyTraitRef<'hir>], TaggedRef<'hir, Lifetime, TraitObjectSyntax>),
3772 Err(rustc_span::ErrorGuaranteed),
3774 Pat(&'hir Ty<'hir>, &'hir TyPat<'hir>),
3776 Infer(Unambig),
3782}
3783
3784#[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)]
3785pub enum InlineAsmOperand<'hir> {
3786 In {
3787 reg: InlineAsmRegOrRegClass,
3788 expr: &'hir Expr<'hir>,
3789 },
3790 Out {
3791 reg: InlineAsmRegOrRegClass,
3792 late: bool,
3793 expr: Option<&'hir Expr<'hir>>,
3794 },
3795 InOut {
3796 reg: InlineAsmRegOrRegClass,
3797 late: bool,
3798 expr: &'hir Expr<'hir>,
3799 },
3800 SplitInOut {
3801 reg: InlineAsmRegOrRegClass,
3802 late: bool,
3803 in_expr: &'hir Expr<'hir>,
3804 out_expr: Option<&'hir Expr<'hir>>,
3805 },
3806 Const {
3807 anon_const: ConstBlock,
3808 },
3809 SymFn {
3810 expr: &'hir Expr<'hir>,
3811 },
3812 SymStatic {
3813 path: QPath<'hir>,
3814 def_id: DefId,
3815 },
3816 Label {
3817 block: &'hir Block<'hir>,
3818 },
3819}
3820
3821impl<'hir> InlineAsmOperand<'hir> {
3822 pub fn reg(&self) -> Option<InlineAsmRegOrRegClass> {
3823 match *self {
3824 Self::In { reg, .. }
3825 | Self::Out { reg, .. }
3826 | Self::InOut { reg, .. }
3827 | Self::SplitInOut { reg, .. } => Some(reg),
3828 Self::Const { .. }
3829 | Self::SymFn { .. }
3830 | Self::SymStatic { .. }
3831 | Self::Label { .. } => None,
3832 }
3833 }
3834
3835 pub fn is_clobber(&self) -> bool {
3836 #[allow(non_exhaustive_omitted_patterns)] match self {
InlineAsmOperand::Out {
reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None } => true,
_ => false,
}matches!(
3837 self,
3838 InlineAsmOperand::Out { reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None }
3839 )
3840 }
3841}
3842
3843#[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)]
3844pub struct InlineAsm<'hir> {
3845 pub asm_macro: ast::AsmMacro,
3846 pub template: &'hir [InlineAsmTemplatePiece],
3847 pub template_strs: &'hir [(Symbol, Option<Symbol>, Span)],
3848 pub operands: &'hir [(InlineAsmOperand<'hir>, Span)],
3849 pub options: InlineAsmOptions,
3850 pub line_spans: &'hir [Span],
3851}
3852
3853impl InlineAsm<'_> {
3854 pub fn contains_label(&self) -> bool {
3855 self.operands.iter().any(|x| #[allow(non_exhaustive_omitted_patterns)] match x.0 {
InlineAsmOperand::Label { .. } => true,
_ => false,
}matches!(x.0, InlineAsmOperand::Label { .. }))
3856 }
3857}
3858
3859#[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)]
3861pub struct Param<'hir> {
3862 #[stable_hasher(ignore)]
3863 pub hir_id: HirId,
3864 pub pat: &'hir Pat<'hir>,
3865 pub ty_span: Span,
3866 pub span: Span,
3867}
3868
3869#[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)]
3871pub struct FnDecl<'hir> {
3872 pub inputs: &'hir [Ty<'hir>],
3876 pub output: FnRetTy<'hir>,
3877 pub c_variadic: bool,
3878 pub implicit_self: ImplicitSelfKind,
3880 pub lifetime_elision_allowed: bool,
3882}
3883
3884impl<'hir> FnDecl<'hir> {
3885 pub fn opt_delegation_sig_id(&self) -> Option<DefId> {
3886 if let FnRetTy::Return(ty) = self.output
3887 && let TyKind::InferDelegation(sig_id, _) = ty.kind
3888 {
3889 return Some(sig_id);
3890 }
3891 None
3892 }
3893}
3894
3895#[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)]
3897pub enum ImplicitSelfKind {
3898 Imm,
3900 Mut,
3902 RefImm,
3904 RefMut,
3906 None,
3909}
3910
3911impl ImplicitSelfKind {
3912 pub fn has_implicit_self(&self) -> bool {
3914 !#[allow(non_exhaustive_omitted_patterns)] match *self {
ImplicitSelfKind::None => true,
_ => false,
}matches!(*self, ImplicitSelfKind::None)
3915 }
3916}
3917
3918#[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)]
3919pub enum IsAsync {
3920 Async(Span),
3921 NotAsync,
3922}
3923
3924impl IsAsync {
3925 pub fn is_async(self) -> bool {
3926 #[allow(non_exhaustive_omitted_patterns)] match self {
IsAsync::Async(_) => true,
_ => false,
}matches!(self, IsAsync::Async(_))
3927 }
3928}
3929
3930#[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)]
3931#[derive(#[automatically_derived]
impl ::core::default::Default for Defaultness {
#[inline]
fn default() -> Defaultness { Self::Final }
}Default)]
3932pub enum Defaultness {
3933 Default {
3934 has_value: bool,
3935 },
3936 #[default]
3937 Final,
3938}
3939
3940impl Defaultness {
3941 pub fn has_value(&self) -> bool {
3942 match *self {
3943 Defaultness::Default { has_value } => has_value,
3944 Defaultness::Final => true,
3945 }
3946 }
3947
3948 pub fn is_final(&self) -> bool {
3949 *self == Defaultness::Final
3950 }
3951
3952 pub fn is_default(&self) -> bool {
3953 #[allow(non_exhaustive_omitted_patterns)] match *self {
Defaultness::Default { .. } => true,
_ => false,
}matches!(*self, Defaultness::Default { .. })
3954 }
3955}
3956
3957#[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)]
3958pub enum FnRetTy<'hir> {
3959 DefaultReturn(Span),
3965 Return(&'hir Ty<'hir>),
3967}
3968
3969impl<'hir> FnRetTy<'hir> {
3970 #[inline]
3971 pub fn span(&self) -> Span {
3972 match *self {
3973 Self::DefaultReturn(span) => span,
3974 Self::Return(ref ty) => ty.span,
3975 }
3976 }
3977
3978 pub fn is_suggestable_infer_ty(&self) -> Option<&'hir Ty<'hir>> {
3979 if let Self::Return(ty) = self
3980 && ty.is_suggestable_infer_ty()
3981 {
3982 return Some(*ty);
3983 }
3984 None
3985 }
3986}
3987
3988#[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)]
3990pub enum ClosureBinder {
3991 Default,
3993 For { span: Span },
3997}
3998
3999#[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)]
4000pub struct Mod<'hir> {
4001 pub spans: ModSpans,
4002 pub item_ids: &'hir [ItemId],
4003}
4004
4005#[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)]
4006pub struct ModSpans {
4007 pub inner_span: Span,
4011 pub inject_use_span: Span,
4012}
4013
4014#[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)]
4015pub struct EnumDef<'hir> {
4016 pub variants: &'hir [Variant<'hir>],
4017}
4018
4019#[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)]
4020pub struct Variant<'hir> {
4021 pub ident: Ident,
4023 #[stable_hasher(ignore)]
4025 pub hir_id: HirId,
4026 pub def_id: LocalDefId,
4027 pub data: VariantData<'hir>,
4029 pub disr_expr: Option<&'hir AnonConst>,
4031 pub span: Span,
4033}
4034
4035#[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)]
4036pub enum UseKind {
4037 Single(Ident),
4044
4045 Glob,
4047
4048 ListStem,
4052}
4053
4054#[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)]
4061pub struct TraitRef<'hir> {
4062 pub path: &'hir Path<'hir>,
4063 #[stable_hasher(ignore)]
4065 pub hir_ref_id: HirId,
4066}
4067
4068impl TraitRef<'_> {
4069 pub fn trait_def_id(&self) -> Option<DefId> {
4071 match self.path.res {
4072 Res::Def(DefKind::Trait | DefKind::TraitAlias, did) => Some(did),
4073 Res::Err => None,
4074 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"),
4075 }
4076 }
4077}
4078
4079#[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)]
4080pub struct PolyTraitRef<'hir> {
4081 pub bound_generic_params: &'hir [GenericParam<'hir>],
4083
4084 pub modifiers: TraitBoundModifiers,
4088
4089 pub trait_ref: TraitRef<'hir>,
4091
4092 pub span: Span,
4093}
4094
4095#[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)]
4096pub struct FieldDef<'hir> {
4097 pub span: Span,
4098 pub vis_span: Span,
4099 pub ident: Ident,
4100 #[stable_hasher(ignore)]
4101 pub hir_id: HirId,
4102 pub def_id: LocalDefId,
4103 pub ty: &'hir Ty<'hir>,
4104 pub safety: Safety,
4105 pub default: Option<&'hir AnonConst>,
4106}
4107
4108impl FieldDef<'_> {
4109 pub fn is_positional(&self) -> bool {
4111 self.ident.as_str().as_bytes()[0].is_ascii_digit()
4112 }
4113}
4114
4115#[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)]
4117pub enum VariantData<'hir> {
4118 Struct { fields: &'hir [FieldDef<'hir>], recovered: ast::Recovered },
4122 Tuple(&'hir [FieldDef<'hir>], #[stable_hasher(ignore)] HirId, LocalDefId),
4126 Unit(#[stable_hasher(ignore)] HirId, LocalDefId),
4130}
4131
4132impl<'hir> VariantData<'hir> {
4133 pub fn fields(&self) -> &'hir [FieldDef<'hir>] {
4135 match *self {
4136 VariantData::Struct { fields, .. } | VariantData::Tuple(fields, ..) => fields,
4137 _ => &[],
4138 }
4139 }
4140
4141 pub fn ctor(&self) -> Option<(CtorKind, HirId, LocalDefId)> {
4142 match *self {
4143 VariantData::Tuple(_, hir_id, def_id) => Some((CtorKind::Fn, hir_id, def_id)),
4144 VariantData::Unit(hir_id, def_id) => Some((CtorKind::Const, hir_id, def_id)),
4145 VariantData::Struct { .. } => None,
4146 }
4147 }
4148
4149 #[inline]
4150 pub fn ctor_kind(&self) -> Option<CtorKind> {
4151 self.ctor().map(|(kind, ..)| kind)
4152 }
4153
4154 #[inline]
4156 pub fn ctor_hir_id(&self) -> Option<HirId> {
4157 self.ctor().map(|(_, hir_id, _)| hir_id)
4158 }
4159
4160 #[inline]
4162 pub fn ctor_def_id(&self) -> Option<LocalDefId> {
4163 self.ctor().map(|(.., def_id)| def_id)
4164 }
4165}
4166
4167#[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)]
4171pub struct ItemId {
4172 pub owner_id: OwnerId,
4173}
4174
4175impl ItemId {
4176 #[inline]
4177 pub fn hir_id(&self) -> HirId {
4178 HirId::make_owner(self.owner_id.def_id)
4180 }
4181}
4182
4183#[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)]
4192pub struct Item<'hir> {
4193 pub owner_id: OwnerId,
4194 pub kind: ItemKind<'hir>,
4195 pub span: Span,
4196 pub vis_span: Span,
4197 pub has_delayed_lints: bool,
4198 pub eii: bool,
4201}
4202
4203impl<'hir> Item<'hir> {
4204 #[inline]
4205 pub fn hir_id(&self) -> HirId {
4206 HirId::make_owner(self.owner_id.def_id)
4208 }
4209
4210 pub fn item_id(&self) -> ItemId {
4211 ItemId { owner_id: self.owner_id }
4212 }
4213
4214 pub fn is_adt(&self) -> bool {
4217 #[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(..))
4218 }
4219
4220 pub fn is_struct_or_union(&self) -> bool {
4222 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
ItemKind::Struct(..) | ItemKind::Union(..) => true,
_ => false,
}matches!(self.kind, ItemKind::Struct(..) | ItemKind::Union(..))
4223 }
4224
4225 self
let ItemKind::Impl(imp) =
&self.kind else { expect_failed("expect_impl", self) };
imp;expect_methods_self_kind! {
4226 expect_extern_crate, (Option<Symbol>, Ident),
4227 ItemKind::ExternCrate(s, ident), (*s, *ident);
4228
4229 expect_use, (&'hir UsePath<'hir>, UseKind), ItemKind::Use(p, uk), (p, *uk);
4230
4231 expect_static, (Mutability, Ident, &'hir Ty<'hir>, BodyId),
4232 ItemKind::Static(mutbl, ident, ty, body), (*mutbl, *ident, ty, *body);
4233
4234 expect_const, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4235 ItemKind::Const(ident, generics, ty, rhs), (*ident, generics, ty, *rhs);
4236
4237 expect_fn, (Ident, &FnSig<'hir>, &'hir Generics<'hir>, BodyId),
4238 ItemKind::Fn { ident, sig, generics, body, .. }, (*ident, sig, generics, *body);
4239
4240 expect_macro, (Ident, &ast::MacroDef, MacroKinds),
4241 ItemKind::Macro(ident, def, mk), (*ident, def, *mk);
4242
4243 expect_mod, (Ident, &'hir Mod<'hir>), ItemKind::Mod(ident, m), (*ident, m);
4244
4245 expect_foreign_mod, (ExternAbi, &'hir [ForeignItemId]),
4246 ItemKind::ForeignMod { abi, items }, (*abi, items);
4247
4248 expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm { asm, .. }, asm;
4249
4250 expect_ty_alias, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4251 ItemKind::TyAlias(ident, generics, ty), (*ident, generics, ty);
4252
4253 expect_enum, (Ident, &'hir Generics<'hir>, &EnumDef<'hir>),
4254 ItemKind::Enum(ident, generics, def), (*ident, generics, def);
4255
4256 expect_struct, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4257 ItemKind::Struct(ident, generics, data), (*ident, generics, data);
4258
4259 expect_union, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4260 ItemKind::Union(ident, generics, data), (*ident, generics, data);
4261
4262 expect_trait,
4263 (
4264 Constness,
4265 IsAuto,
4266 Safety,
4267 Ident,
4268 &'hir Generics<'hir>,
4269 GenericBounds<'hir>,
4270 &'hir [TraitItemId]
4271 ),
4272 ItemKind::Trait(constness, is_auto, safety, ident, generics, bounds, items),
4273 (*constness, *is_auto, *safety, *ident, generics, bounds, items);
4274
4275 expect_trait_alias, (Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4276 ItemKind::TraitAlias(constness, ident, generics, bounds), (*constness, *ident, generics, bounds);
4277
4278 expect_impl, &Impl<'hir>, ItemKind::Impl(imp), imp;
4279 }
4280}
4281
4282#[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)]
4283#[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)]
4284pub enum Safety {
4285 #[default]
4290 Unsafe,
4291 Safe,
4292}
4293
4294impl Safety {
4295 pub fn prefix_str(self) -> &'static str {
4296 match self {
4297 Self::Unsafe => "unsafe ",
4298 Self::Safe => "",
4299 }
4300 }
4301
4302 #[inline]
4303 pub fn is_unsafe(self) -> bool {
4304 !self.is_safe()
4305 }
4306
4307 #[inline]
4308 pub fn is_safe(self) -> bool {
4309 match self {
4310 Self::Unsafe => false,
4311 Self::Safe => true,
4312 }
4313 }
4314}
4315
4316impl fmt::Display for Safety {
4317 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4318 f.write_str(match *self {
4319 Self::Unsafe => "unsafe",
4320 Self::Safe => "safe",
4321 })
4322 }
4323}
4324
4325#[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)]
4326#[derive(#[automatically_derived]
impl ::core::default::Default for Constness {
#[inline]
fn default() -> Constness { Self::Const }
}Default)]
4327pub enum Constness {
4328 #[default]
4329 Const,
4330 NotConst,
4331}
4332
4333impl fmt::Display for Constness {
4334 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4335 f.write_str(match *self {
4336 Self::Const => "const",
4337 Self::NotConst => "non-const",
4338 })
4339 }
4340}
4341
4342#[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)]
4347pub enum HeaderSafety {
4348 SafeTargetFeatures,
4354 Normal(Safety),
4355}
4356
4357impl From<Safety> for HeaderSafety {
4358 fn from(v: Safety) -> Self {
4359 Self::Normal(v)
4360 }
4361}
4362
4363#[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)]
4364pub struct FnHeader {
4365 pub safety: HeaderSafety,
4366 pub constness: Constness,
4367 pub asyncness: IsAsync,
4368 pub abi: ExternAbi,
4369}
4370
4371impl FnHeader {
4372 pub fn is_async(&self) -> bool {
4373 #[allow(non_exhaustive_omitted_patterns)] match self.asyncness {
IsAsync::Async(_) => true,
_ => false,
}matches!(self.asyncness, IsAsync::Async(_))
4374 }
4375
4376 pub fn is_const(&self) -> bool {
4377 #[allow(non_exhaustive_omitted_patterns)] match self.constness {
Constness::Const => true,
_ => false,
}matches!(self.constness, Constness::Const)
4378 }
4379
4380 pub fn is_unsafe(&self) -> bool {
4381 self.safety().is_unsafe()
4382 }
4383
4384 pub fn is_safe(&self) -> bool {
4385 self.safety().is_safe()
4386 }
4387
4388 pub fn safety(&self) -> Safety {
4389 match self.safety {
4390 HeaderSafety::SafeTargetFeatures => Safety::Unsafe,
4391 HeaderSafety::Normal(safety) => safety,
4392 }
4393 }
4394}
4395
4396#[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)]
4397pub enum ItemKind<'hir> {
4398 ExternCrate(Option<Symbol>, Ident),
4402
4403 Use(&'hir UsePath<'hir>, UseKind),
4409
4410 Static(Mutability, Ident, &'hir Ty<'hir>, BodyId),
4412 Const(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4414 Fn {
4416 sig: FnSig<'hir>,
4417 ident: Ident,
4418 generics: &'hir Generics<'hir>,
4419 body: BodyId,
4420 has_body: bool,
4424 },
4425 Macro(Ident, &'hir ast::MacroDef, MacroKinds),
4427 Mod(Ident, &'hir Mod<'hir>),
4429 ForeignMod { abi: ExternAbi, items: &'hir [ForeignItemId] },
4431 GlobalAsm {
4433 asm: &'hir InlineAsm<'hir>,
4434 fake_body: BodyId,
4440 },
4441 TyAlias(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4443 Enum(Ident, &'hir Generics<'hir>, EnumDef<'hir>),
4445 Struct(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4447 Union(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4449 Trait(
4451 Constness,
4452 IsAuto,
4453 Safety,
4454 Ident,
4455 &'hir Generics<'hir>,
4456 GenericBounds<'hir>,
4457 &'hir [TraitItemId],
4458 ),
4459 TraitAlias(Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4461
4462 Impl(Impl<'hir>),
4464}
4465
4466#[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)]
4471pub struct Impl<'hir> {
4472 pub generics: &'hir Generics<'hir>,
4473 pub of_trait: Option<&'hir TraitImplHeader<'hir>>,
4474 pub self_ty: &'hir Ty<'hir>,
4475 pub items: &'hir [ImplItemId],
4476 pub constness: Constness,
4477}
4478
4479#[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)]
4480pub struct TraitImplHeader<'hir> {
4481 pub safety: Safety,
4482 pub polarity: ImplPolarity,
4483 pub defaultness: Defaultness,
4484 pub defaultness_span: Option<Span>,
4487 pub trait_ref: TraitRef<'hir>,
4488}
4489
4490impl ItemKind<'_> {
4491 pub fn ident(&self) -> Option<Ident> {
4492 match *self {
4493 ItemKind::ExternCrate(_, ident)
4494 | ItemKind::Use(_, UseKind::Single(ident))
4495 | ItemKind::Static(_, ident, ..)
4496 | ItemKind::Const(ident, ..)
4497 | ItemKind::Fn { ident, .. }
4498 | ItemKind::Macro(ident, ..)
4499 | ItemKind::Mod(ident, ..)
4500 | ItemKind::TyAlias(ident, ..)
4501 | ItemKind::Enum(ident, ..)
4502 | ItemKind::Struct(ident, ..)
4503 | ItemKind::Union(ident, ..)
4504 | ItemKind::Trait(_, _, _, ident, ..)
4505 | ItemKind::TraitAlias(_, ident, ..) => Some(ident),
4506
4507 ItemKind::Use(_, UseKind::Glob | UseKind::ListStem)
4508 | ItemKind::ForeignMod { .. }
4509 | ItemKind::GlobalAsm { .. }
4510 | ItemKind::Impl(_) => None,
4511 }
4512 }
4513
4514 pub fn generics(&self) -> Option<&Generics<'_>> {
4515 Some(match self {
4516 ItemKind::Fn { generics, .. }
4517 | ItemKind::TyAlias(_, generics, _)
4518 | ItemKind::Const(_, generics, _, _)
4519 | ItemKind::Enum(_, generics, _)
4520 | ItemKind::Struct(_, generics, _)
4521 | ItemKind::Union(_, generics, _)
4522 | ItemKind::Trait(_, _, _, _, generics, _, _)
4523 | ItemKind::TraitAlias(_, _, generics, _)
4524 | ItemKind::Impl(Impl { generics, .. }) => generics,
4525 _ => return None,
4526 })
4527 }
4528
4529 pub fn recovered(&self) -> bool {
4530 match self {
4531 ItemKind::Struct(
4532 _,
4533 _,
4534 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4535 ) => true,
4536 ItemKind::Union(
4537 _,
4538 _,
4539 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4540 ) => true,
4541 ItemKind::Enum(_, _, def) => def.variants.iter().any(|v| match v.data {
4542 VariantData::Struct { recovered: ast::Recovered::Yes(_), .. } => true,
4543 _ => false,
4544 }),
4545 _ => false,
4546 }
4547 }
4548}
4549
4550#[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)]
4554pub struct ForeignItemId {
4555 pub owner_id: OwnerId,
4556}
4557
4558impl ForeignItemId {
4559 #[inline]
4560 pub fn hir_id(&self) -> HirId {
4561 HirId::make_owner(self.owner_id.def_id)
4563 }
4564}
4565
4566#[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)]
4567pub struct ForeignItem<'hir> {
4568 pub ident: Ident,
4569 pub kind: ForeignItemKind<'hir>,
4570 pub owner_id: OwnerId,
4571 pub span: Span,
4572 pub vis_span: Span,
4573 pub has_delayed_lints: bool,
4574}
4575
4576impl ForeignItem<'_> {
4577 #[inline]
4578 pub fn hir_id(&self) -> HirId {
4579 HirId::make_owner(self.owner_id.def_id)
4581 }
4582
4583 pub fn foreign_item_id(&self) -> ForeignItemId {
4584 ForeignItemId { owner_id: self.owner_id }
4585 }
4586}
4587
4588#[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)]
4590pub enum ForeignItemKind<'hir> {
4591 Fn(FnSig<'hir>, &'hir [Option<Ident>], &'hir Generics<'hir>),
4598 Static(&'hir Ty<'hir>, Mutability, Safety),
4600 Type,
4602}
4603
4604#[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)]
4606pub struct Upvar {
4607 pub span: Span,
4609}
4610
4611#[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)]
4615pub struct TraitCandidate {
4616 pub def_id: DefId,
4617 pub import_ids: SmallVec<[LocalDefId; 1]>,
4618 pub lint_ambiguous: bool,
4623}
4624
4625#[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)]
4626pub enum OwnerNode<'hir> {
4627 Item(&'hir Item<'hir>),
4628 ForeignItem(&'hir ForeignItem<'hir>),
4629 TraitItem(&'hir TraitItem<'hir>),
4630 ImplItem(&'hir ImplItem<'hir>),
4631 Crate(&'hir Mod<'hir>),
4632 Synthetic,
4633}
4634
4635impl<'hir> OwnerNode<'hir> {
4636 pub fn span(&self) -> Span {
4637 match self {
4638 OwnerNode::Item(Item { span, .. })
4639 | OwnerNode::ForeignItem(ForeignItem { span, .. })
4640 | OwnerNode::ImplItem(ImplItem { span, .. })
4641 | OwnerNode::TraitItem(TraitItem { span, .. }) => *span,
4642 OwnerNode::Crate(Mod { spans: ModSpans { inner_span, .. }, .. }) => *inner_span,
4643 OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4644 }
4645 }
4646
4647 pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
4648 match self {
4649 OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4650 | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4651 | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4652 | OwnerNode::ForeignItem(ForeignItem {
4653 kind: ForeignItemKind::Fn(fn_sig, _, _), ..
4654 }) => Some(fn_sig),
4655 _ => None,
4656 }
4657 }
4658
4659 pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
4660 match self {
4661 OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4662 | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4663 | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4664 | OwnerNode::ForeignItem(ForeignItem {
4665 kind: ForeignItemKind::Fn(fn_sig, _, _), ..
4666 }) => Some(fn_sig.decl),
4667 _ => None,
4668 }
4669 }
4670
4671 pub fn body_id(&self) -> Option<BodyId> {
4672 match self {
4673 OwnerNode::Item(Item {
4674 kind:
4675 ItemKind::Static(_, _, _, body)
4676 | ItemKind::Const(.., ConstItemRhs::Body(body))
4677 | ItemKind::Fn { body, .. },
4678 ..
4679 })
4680 | OwnerNode::TraitItem(TraitItem {
4681 kind:
4682 TraitItemKind::Fn(_, TraitFn::Provided(body))
4683 | TraitItemKind::Const(_, Some(ConstItemRhs::Body(body))),
4684 ..
4685 })
4686 | OwnerNode::ImplItem(ImplItem {
4687 kind: ImplItemKind::Fn(_, body) | ImplItemKind::Const(_, ConstItemRhs::Body(body)),
4688 ..
4689 }) => Some(*body),
4690 _ => None,
4691 }
4692 }
4693
4694 pub fn generics(self) -> Option<&'hir Generics<'hir>> {
4695 Node::generics(self.into())
4696 }
4697
4698 pub fn def_id(self) -> OwnerId {
4699 match self {
4700 OwnerNode::Item(Item { owner_id, .. })
4701 | OwnerNode::TraitItem(TraitItem { owner_id, .. })
4702 | OwnerNode::ImplItem(ImplItem { owner_id, .. })
4703 | OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
4704 OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
4705 OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4706 }
4707 }
4708
4709 pub fn is_impl_block(&self) -> bool {
4711 #[allow(non_exhaustive_omitted_patterns)] match self {
OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }) => true,
_ => false,
}matches!(self, OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }))
4712 }
4713
4714 self
let OwnerNode::TraitItem(n) =
self else { expect_failed("expect_trait_item", self) };
n;expect_methods_self! {
4715 expect_item, &'hir Item<'hir>, OwnerNode::Item(n), n;
4716 expect_foreign_item, &'hir ForeignItem<'hir>, OwnerNode::ForeignItem(n), n;
4717 expect_impl_item, &'hir ImplItem<'hir>, OwnerNode::ImplItem(n), n;
4718 expect_trait_item, &'hir TraitItem<'hir>, OwnerNode::TraitItem(n), n;
4719 }
4720}
4721
4722impl<'hir> From<&'hir Item<'hir>> for OwnerNode<'hir> {
4723 fn from(val: &'hir Item<'hir>) -> Self {
4724 OwnerNode::Item(val)
4725 }
4726}
4727
4728impl<'hir> From<&'hir ForeignItem<'hir>> for OwnerNode<'hir> {
4729 fn from(val: &'hir ForeignItem<'hir>) -> Self {
4730 OwnerNode::ForeignItem(val)
4731 }
4732}
4733
4734impl<'hir> From<&'hir ImplItem<'hir>> for OwnerNode<'hir> {
4735 fn from(val: &'hir ImplItem<'hir>) -> Self {
4736 OwnerNode::ImplItem(val)
4737 }
4738}
4739
4740impl<'hir> From<&'hir TraitItem<'hir>> for OwnerNode<'hir> {
4741 fn from(val: &'hir TraitItem<'hir>) -> Self {
4742 OwnerNode::TraitItem(val)
4743 }
4744}
4745
4746impl<'hir> From<OwnerNode<'hir>> for Node<'hir> {
4747 fn from(val: OwnerNode<'hir>) -> Self {
4748 match val {
4749 OwnerNode::Item(n) => Node::Item(n),
4750 OwnerNode::ForeignItem(n) => Node::ForeignItem(n),
4751 OwnerNode::ImplItem(n) => Node::ImplItem(n),
4752 OwnerNode::TraitItem(n) => Node::TraitItem(n),
4753 OwnerNode::Crate(n) => Node::Crate(n),
4754 OwnerNode::Synthetic => Node::Synthetic,
4755 }
4756 }
4757}
4758
4759#[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)]
4760pub enum Node<'hir> {
4761 Param(&'hir Param<'hir>),
4762 Item(&'hir Item<'hir>),
4763 ForeignItem(&'hir ForeignItem<'hir>),
4764 TraitItem(&'hir TraitItem<'hir>),
4765 ImplItem(&'hir ImplItem<'hir>),
4766 Variant(&'hir Variant<'hir>),
4767 Field(&'hir FieldDef<'hir>),
4768 AnonConst(&'hir AnonConst),
4769 ConstBlock(&'hir ConstBlock),
4770 ConstArg(&'hir ConstArg<'hir>),
4771 Expr(&'hir Expr<'hir>),
4772 ExprField(&'hir ExprField<'hir>),
4773 ConstArgExprField(&'hir ConstArgExprField<'hir>),
4774 Stmt(&'hir Stmt<'hir>),
4775 PathSegment(&'hir PathSegment<'hir>),
4776 Ty(&'hir Ty<'hir>),
4777 AssocItemConstraint(&'hir AssocItemConstraint<'hir>),
4778 TraitRef(&'hir TraitRef<'hir>),
4779 OpaqueTy(&'hir OpaqueTy<'hir>),
4780 TyPat(&'hir TyPat<'hir>),
4781 Pat(&'hir Pat<'hir>),
4782 PatField(&'hir PatField<'hir>),
4783 PatExpr(&'hir PatExpr<'hir>),
4787 Arm(&'hir Arm<'hir>),
4788 Block(&'hir Block<'hir>),
4789 LetStmt(&'hir LetStmt<'hir>),
4790 Ctor(&'hir VariantData<'hir>),
4793 Lifetime(&'hir Lifetime),
4794 GenericParam(&'hir GenericParam<'hir>),
4795 Crate(&'hir Mod<'hir>),
4796 Infer(&'hir InferArg),
4797 WherePredicate(&'hir WherePredicate<'hir>),
4798 PreciseCapturingNonLifetimeArg(&'hir PreciseCapturingNonLifetimeArg),
4799 Synthetic,
4801 Err(Span),
4802}
4803
4804impl<'hir> Node<'hir> {
4805 pub fn ident(&self) -> Option<Ident> {
4820 match self {
4821 Node::Item(item) => item.kind.ident(),
4822 Node::TraitItem(TraitItem { ident, .. })
4823 | Node::ImplItem(ImplItem { ident, .. })
4824 | Node::ForeignItem(ForeignItem { ident, .. })
4825 | Node::Field(FieldDef { ident, .. })
4826 | Node::Variant(Variant { ident, .. })
4827 | Node::PathSegment(PathSegment { ident, .. }) => Some(*ident),
4828 Node::Lifetime(lt) => Some(lt.ident),
4829 Node::GenericParam(p) => Some(p.name.ident()),
4830 Node::AssocItemConstraint(c) => Some(c.ident),
4831 Node::PatField(f) => Some(f.ident),
4832 Node::ExprField(f) => Some(f.ident),
4833 Node::ConstArgExprField(f) => Some(f.field),
4834 Node::PreciseCapturingNonLifetimeArg(a) => Some(a.ident),
4835 Node::Param(..)
4836 | Node::AnonConst(..)
4837 | Node::ConstBlock(..)
4838 | Node::ConstArg(..)
4839 | Node::Expr(..)
4840 | Node::Stmt(..)
4841 | Node::Block(..)
4842 | Node::Ctor(..)
4843 | Node::Pat(..)
4844 | Node::TyPat(..)
4845 | Node::PatExpr(..)
4846 | Node::Arm(..)
4847 | Node::LetStmt(..)
4848 | Node::Crate(..)
4849 | Node::Ty(..)
4850 | Node::TraitRef(..)
4851 | Node::OpaqueTy(..)
4852 | Node::Infer(..)
4853 | Node::WherePredicate(..)
4854 | Node::Synthetic
4855 | Node::Err(..) => None,
4856 }
4857 }
4858
4859 pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
4860 match self {
4861 Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4862 | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4863 | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4864 | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
4865 Some(fn_sig.decl)
4866 }
4867 Node::Expr(Expr { kind: ExprKind::Closure(Closure { fn_decl, .. }), .. }) => {
4868 Some(fn_decl)
4869 }
4870 _ => None,
4871 }
4872 }
4873
4874 pub fn impl_block_of_trait(self, trait_def_id: DefId) -> Option<&'hir Impl<'hir>> {
4876 if let Node::Item(Item { kind: ItemKind::Impl(impl_block), .. }) = self
4877 && let Some(of_trait) = impl_block.of_trait
4878 && let Some(trait_id) = of_trait.trait_ref.trait_def_id()
4879 && trait_id == trait_def_id
4880 {
4881 Some(impl_block)
4882 } else {
4883 None
4884 }
4885 }
4886
4887 pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
4888 match self {
4889 Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4890 | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4891 | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4892 | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
4893 Some(fn_sig)
4894 }
4895 _ => None,
4896 }
4897 }
4898
4899 pub fn ty(self) -> Option<&'hir Ty<'hir>> {
4901 match self {
4902 Node::Item(it) => match it.kind {
4903 ItemKind::TyAlias(_, _, ty)
4904 | ItemKind::Static(_, _, ty, _)
4905 | ItemKind::Const(_, _, ty, _) => Some(ty),
4906 ItemKind::Impl(impl_item) => Some(&impl_item.self_ty),
4907 _ => None,
4908 },
4909 Node::TraitItem(it) => match it.kind {
4910 TraitItemKind::Const(ty, _) => Some(ty),
4911 TraitItemKind::Type(_, ty) => ty,
4912 _ => None,
4913 },
4914 Node::ImplItem(it) => match it.kind {
4915 ImplItemKind::Const(ty, _) => Some(ty),
4916 ImplItemKind::Type(ty) => Some(ty),
4917 _ => None,
4918 },
4919 Node::ForeignItem(it) => match it.kind {
4920 ForeignItemKind::Static(ty, ..) => Some(ty),
4921 _ => None,
4922 },
4923 Node::GenericParam(param) => match param.kind {
4924 GenericParamKind::Lifetime { .. } => None,
4925 GenericParamKind::Type { default, .. } => default,
4926 GenericParamKind::Const { ty, .. } => Some(ty),
4927 },
4928 _ => None,
4929 }
4930 }
4931
4932 pub fn alias_ty(self) -> Option<&'hir Ty<'hir>> {
4933 match self {
4934 Node::Item(Item { kind: ItemKind::TyAlias(_, _, ty), .. }) => Some(ty),
4935 _ => None,
4936 }
4937 }
4938
4939 #[inline]
4940 pub fn associated_body(&self) -> Option<(LocalDefId, BodyId)> {
4941 match self {
4942 Node::Item(Item {
4943 owner_id,
4944 kind:
4945 ItemKind::Const(.., ConstItemRhs::Body(body))
4946 | ItemKind::Static(.., body)
4947 | ItemKind::Fn { body, .. },
4948 ..
4949 })
4950 | Node::TraitItem(TraitItem {
4951 owner_id,
4952 kind:
4953 TraitItemKind::Const(.., Some(ConstItemRhs::Body(body)))
4954 | TraitItemKind::Fn(_, TraitFn::Provided(body)),
4955 ..
4956 })
4957 | Node::ImplItem(ImplItem {
4958 owner_id,
4959 kind: ImplItemKind::Const(.., ConstItemRhs::Body(body)) | ImplItemKind::Fn(_, body),
4960 ..
4961 }) => Some((owner_id.def_id, *body)),
4962
4963 Node::Item(Item {
4964 owner_id, kind: ItemKind::GlobalAsm { asm: _, fake_body }, ..
4965 }) => Some((owner_id.def_id, *fake_body)),
4966
4967 Node::Expr(Expr { kind: ExprKind::Closure(Closure { def_id, body, .. }), .. }) => {
4968 Some((*def_id, *body))
4969 }
4970
4971 Node::AnonConst(constant) => Some((constant.def_id, constant.body)),
4972 Node::ConstBlock(constant) => Some((constant.def_id, constant.body)),
4973
4974 _ => None,
4975 }
4976 }
4977
4978 pub fn body_id(&self) -> Option<BodyId> {
4979 Some(self.associated_body()?.1)
4980 }
4981
4982 pub fn generics(self) -> Option<&'hir Generics<'hir>> {
4983 match self {
4984 Node::ForeignItem(ForeignItem {
4985 kind: ForeignItemKind::Fn(_, _, generics), ..
4986 })
4987 | Node::TraitItem(TraitItem { generics, .. })
4988 | Node::ImplItem(ImplItem { generics, .. }) => Some(generics),
4989 Node::Item(item) => item.kind.generics(),
4990 _ => None,
4991 }
4992 }
4993
4994 pub fn as_owner(self) -> Option<OwnerNode<'hir>> {
4995 match self {
4996 Node::Item(i) => Some(OwnerNode::Item(i)),
4997 Node::ForeignItem(i) => Some(OwnerNode::ForeignItem(i)),
4998 Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
4999 Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
5000 Node::Crate(i) => Some(OwnerNode::Crate(i)),
5001 Node::Synthetic => Some(OwnerNode::Synthetic),
5002 _ => None,
5003 }
5004 }
5005
5006 pub fn fn_kind(self) -> Option<FnKind<'hir>> {
5007 match self {
5008 Node::Item(i) => match i.kind {
5009 ItemKind::Fn { ident, sig, generics, .. } => {
5010 Some(FnKind::ItemFn(ident, generics, sig.header))
5011 }
5012 _ => None,
5013 },
5014 Node::TraitItem(ti) => match ti.kind {
5015 TraitItemKind::Fn(ref sig, _) => Some(FnKind::Method(ti.ident, sig)),
5016 _ => None,
5017 },
5018 Node::ImplItem(ii) => match ii.kind {
5019 ImplItemKind::Fn(ref sig, _) => Some(FnKind::Method(ii.ident, sig)),
5020 _ => None,
5021 },
5022 Node::Expr(e) => match e.kind {
5023 ExprKind::Closure { .. } => Some(FnKind::Closure),
5024 _ => None,
5025 },
5026 _ => None,
5027 }
5028 }
5029
5030 self
let Node::Expr(Expr { kind: ExprKind::Closure(n), .. }) =
self else { expect_failed("expect_closure", self) };
n;expect_methods_self! {
5031 expect_param, &'hir Param<'hir>, Node::Param(n), n;
5032 expect_item, &'hir Item<'hir>, Node::Item(n), n;
5033 expect_foreign_item, &'hir ForeignItem<'hir>, Node::ForeignItem(n), n;
5034 expect_trait_item, &'hir TraitItem<'hir>, Node::TraitItem(n), n;
5035 expect_impl_item, &'hir ImplItem<'hir>, Node::ImplItem(n), n;
5036 expect_variant, &'hir Variant<'hir>, Node::Variant(n), n;
5037 expect_field, &'hir FieldDef<'hir>, Node::Field(n), n;
5038 expect_anon_const, &'hir AnonConst, Node::AnonConst(n), n;
5039 expect_inline_const, &'hir ConstBlock, Node::ConstBlock(n), n;
5040 expect_expr, &'hir Expr<'hir>, Node::Expr(n), n;
5041 expect_expr_field, &'hir ExprField<'hir>, Node::ExprField(n), n;
5042 expect_stmt, &'hir Stmt<'hir>, Node::Stmt(n), n;
5043 expect_path_segment, &'hir PathSegment<'hir>, Node::PathSegment(n), n;
5044 expect_ty, &'hir Ty<'hir>, Node::Ty(n), n;
5045 expect_assoc_item_constraint, &'hir AssocItemConstraint<'hir>, Node::AssocItemConstraint(n), n;
5046 expect_trait_ref, &'hir TraitRef<'hir>, Node::TraitRef(n), n;
5047 expect_opaque_ty, &'hir OpaqueTy<'hir>, Node::OpaqueTy(n), n;
5048 expect_pat, &'hir Pat<'hir>, Node::Pat(n), n;
5049 expect_pat_field, &'hir PatField<'hir>, Node::PatField(n), n;
5050 expect_arm, &'hir Arm<'hir>, Node::Arm(n), n;
5051 expect_block, &'hir Block<'hir>, Node::Block(n), n;
5052 expect_let_stmt, &'hir LetStmt<'hir>, Node::LetStmt(n), n;
5053 expect_ctor, &'hir VariantData<'hir>, Node::Ctor(n), n;
5054 expect_lifetime, &'hir Lifetime, Node::Lifetime(n), n;
5055 expect_generic_param, &'hir GenericParam<'hir>, Node::GenericParam(n), n;
5056 expect_crate, &'hir Mod<'hir>, Node::Crate(n), n;
5057 expect_infer, &'hir InferArg, Node::Infer(n), n;
5058 expect_closure, &'hir Closure<'hir>, Node::Expr(Expr { kind: ExprKind::Closure(n), .. }), n;
5059 }
5060}
5061
5062#[cfg(target_pointer_width = "64")]
5064mod size_asserts {
5065 use rustc_data_structures::static_assert_size;
5066
5067 use super::*;
5068 const _: [(); 48] = [(); ::std::mem::size_of::<Block<'_>>()];static_assert_size!(Block<'_>, 48);
5070 const _: [(); 24] = [(); ::std::mem::size_of::<Body<'_>>()];static_assert_size!(Body<'_>, 24);
5071 const _: [(); 64] = [(); ::std::mem::size_of::<Expr<'_>>()];static_assert_size!(Expr<'_>, 64);
5072 const _: [(); 48] = [(); ::std::mem::size_of::<ExprKind<'_>>()];static_assert_size!(ExprKind<'_>, 48);
5073 const _: [(); 40] = [(); ::std::mem::size_of::<FnDecl<'_>>()];static_assert_size!(FnDecl<'_>, 40);
5074 const _: [(); 96] = [(); ::std::mem::size_of::<ForeignItem<'_>>()];static_assert_size!(ForeignItem<'_>, 96);
5075 const _: [(); 56] = [(); ::std::mem::size_of::<ForeignItemKind<'_>>()];static_assert_size!(ForeignItemKind<'_>, 56);
5076 const _: [(); 16] = [(); ::std::mem::size_of::<GenericArg<'_>>()];static_assert_size!(GenericArg<'_>, 16);
5077 const _: [(); 64] = [(); ::std::mem::size_of::<GenericBound<'_>>()];static_assert_size!(GenericBound<'_>, 64);
5078 const _: [(); 56] = [(); ::std::mem::size_of::<Generics<'_>>()];static_assert_size!(Generics<'_>, 56);
5079 const _: [(); 48] = [(); ::std::mem::size_of::<Impl<'_>>()];static_assert_size!(Impl<'_>, 48);
5080 const _: [(); 88] = [(); ::std::mem::size_of::<ImplItem<'_>>()];static_assert_size!(ImplItem<'_>, 88);
5081 const _: [(); 40] = [(); ::std::mem::size_of::<ImplItemKind<'_>>()];static_assert_size!(ImplItemKind<'_>, 40);
5082 const _: [(); 88] = [(); ::std::mem::size_of::<Item<'_>>()];static_assert_size!(Item<'_>, 88);
5083 const _: [(); 64] = [(); ::std::mem::size_of::<ItemKind<'_>>()];static_assert_size!(ItemKind<'_>, 64);
5084 const _: [(); 64] = [(); ::std::mem::size_of::<LetStmt<'_>>()];static_assert_size!(LetStmt<'_>, 64);
5085 const _: [(); 32] = [(); ::std::mem::size_of::<Param<'_>>()];static_assert_size!(Param<'_>, 32);
5086 const _: [(); 80] = [(); ::std::mem::size_of::<Pat<'_>>()];static_assert_size!(Pat<'_>, 80);
5087 const _: [(); 56] = [(); ::std::mem::size_of::<PatKind<'_>>()];static_assert_size!(PatKind<'_>, 56);
5088 const _: [(); 40] = [(); ::std::mem::size_of::<Path<'_>>()];static_assert_size!(Path<'_>, 40);
5089 const _: [(); 48] = [(); ::std::mem::size_of::<PathSegment<'_>>()];static_assert_size!(PathSegment<'_>, 48);
5090 const _: [(); 24] = [(); ::std::mem::size_of::<QPath<'_>>()];static_assert_size!(QPath<'_>, 24);
5091 const _: [(); 12] = [(); ::std::mem::size_of::<Res>()];static_assert_size!(Res, 12);
5092 const _: [(); 32] = [(); ::std::mem::size_of::<Stmt<'_>>()];static_assert_size!(Stmt<'_>, 32);
5093 const _: [(); 16] = [(); ::std::mem::size_of::<StmtKind<'_>>()];static_assert_size!(StmtKind<'_>, 16);
5094 const _: [(); 48] = [(); ::std::mem::size_of::<TraitImplHeader<'_>>()];static_assert_size!(TraitImplHeader<'_>, 48);
5095 const _: [(); 88] = [(); ::std::mem::size_of::<TraitItem<'_>>()];static_assert_size!(TraitItem<'_>, 88);
5096 const _: [(); 48] = [(); ::std::mem::size_of::<TraitItemKind<'_>>()];static_assert_size!(TraitItemKind<'_>, 48);
5097 const _: [(); 48] = [(); ::std::mem::size_of::<Ty<'_>>()];static_assert_size!(Ty<'_>, 48);
5098 const _: [(); 32] = [(); ::std::mem::size_of::<TyKind<'_>>()];static_assert_size!(TyKind<'_>, 32);
5099 }
5101
5102#[cfg(test)]
5103mod tests;