1use std::fmt::Debug;
4use std::ops;
5
6use rustc_data_structures::outline;
7use thin_vec::ThinVec;
8use tracing::instrument;
9
10use super::interpret::GlobalAlloc;
11use super::*;
12use crate::ty::{CoroutineArgsExt, Unnormalized};
13
14#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for Statement<'tcx> {
#[inline]
fn clone(&self) -> Statement<'tcx> {
Statement {
source_info: ::core::clone::Clone::clone(&self.source_info),
kind: ::core::clone::Clone::clone(&self.kind),
debuginfos: ::core::clone::Clone::clone(&self.debuginfos),
}
}
}Clone, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for Statement<'tcx> {
fn encode(&self, __encoder: &mut __E) {
let Statement {
source_info: ref __binding_0,
kind: ref __binding_1,
debuginfos: ref __binding_2 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for Statement<'tcx> {
fn decode(__decoder: &mut __D) -> Self {
Statement {
source_info: ::rustc_serialize::Decodable::decode(__decoder),
kind: ::rustc_serialize::Decodable::decode(__decoder),
debuginfos: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable, const _: () =
{
impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
Statement<'tcx> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
Statement {
source_info: ref __binding_0,
kind: ref __binding_1,
debuginfos: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for Statement<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
Statement {
source_info: __binding_0,
kind: __binding_1,
debuginfos: __binding_2 } => {
Statement {
source_info: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
kind: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
debuginfos: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_2,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
Statement {
source_info: __binding_0,
kind: __binding_1,
debuginfos: __binding_2 } => {
Statement {
source_info: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
kind: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
debuginfos: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_2,
__folder),
}
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for Statement<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
Statement {
source_info: ref __binding_0,
kind: ref __binding_1,
debuginfos: ref __binding_2 } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_2,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
19#[non_exhaustive]
20pub struct Statement<'tcx> {
21 pub source_info: SourceInfo,
22 pub kind: StatementKind<'tcx>,
23 pub debuginfos: StmtDebugInfos<'tcx>,
25}
26
27impl<'tcx> Statement<'tcx> {
28 pub fn make_nop(&mut self, drop_debuginfo: bool) {
31 if self.kind == StatementKind::Nop {
32 return;
33 }
34 let replaced_stmt = std::mem::replace(&mut self.kind, StatementKind::Nop);
35 if !drop_debuginfo {
36 let Some(debuginfo) = replaced_stmt.as_debuginfo() else {
37 crate::util::bug::bug_fmt(format_args!("debuginfo is not yet supported."))bug!("debuginfo is not yet supported.")
38 };
39 self.debuginfos.push(debuginfo);
40 }
41 }
42
43 pub fn new(source_info: SourceInfo, kind: StatementKind<'tcx>) -> Self {
44 Statement { source_info, kind, debuginfos: StmtDebugInfos::default() }
45 }
46}
47
48impl<'tcx> StatementKind<'tcx> {
49 pub const fn name(&self) -> &'static str {
52 match self {
53 StatementKind::Assign(..) => "Assign",
54 StatementKind::FakeRead(..) => "FakeRead",
55 StatementKind::SetDiscriminant { .. } => "SetDiscriminant",
56 StatementKind::StorageLive(..) => "StorageLive",
57 StatementKind::StorageDead(..) => "StorageDead",
58 StatementKind::PlaceMention(..) => "PlaceMention",
59 StatementKind::AscribeUserType(..) => "AscribeUserType",
60 StatementKind::Coverage(..) => "Coverage",
61 StatementKind::Intrinsic(..) => "Intrinsic",
62 StatementKind::ConstEvalCounter => "ConstEvalCounter",
63 StatementKind::Nop => "Nop",
64 StatementKind::BackwardIncompatibleDropHint { .. } => "BackwardIncompatibleDropHint",
65 }
66 }
67 pub fn as_assign_mut(&mut self) -> Option<&mut (Place<'tcx>, Rvalue<'tcx>)> {
68 match self {
69 StatementKind::Assign(x) => Some(x),
70 _ => None,
71 }
72 }
73
74 pub fn as_assign(&self) -> Option<&(Place<'tcx>, Rvalue<'tcx>)> {
75 match self {
76 StatementKind::Assign(x) => Some(x),
77 _ => None,
78 }
79 }
80
81 pub fn as_debuginfo(&self) -> Option<StmtDebugInfo<'tcx>> {
82 match self {
83 StatementKind::Assign((place, Rvalue::Ref(_, _, ref_place)))
84 if let Some(local) = place.as_local() =>
85 {
86 Some(StmtDebugInfo::AssignRef(local, *ref_place))
87 }
88 _ => None,
89 }
90 }
91}
92
93#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for PlaceTy<'tcx> { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl<'tcx> ::core::clone::TrivialClone for PlaceTy<'tcx> { }
#[automatically_derived]
impl<'tcx> ::core::clone::Clone for PlaceTy<'tcx> {
#[inline]
fn clone(&self) -> PlaceTy<'tcx> {
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
let _: ::core::clone::AssertParamIsClone<Option<VariantIdx>>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for PlaceTy<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "PlaceTy", "ty",
&self.ty, "variant_index", &&self.variant_index)
}
}Debug, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for PlaceTy<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
PlaceTy { ty: __binding_0, variant_index: __binding_1 } => {
PlaceTy {
ty: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
variant_index: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
PlaceTy { ty: __binding_0, variant_index: __binding_1 } => {
PlaceTy {
ty: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
variant_index: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for PlaceTy<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
PlaceTy {
ty: ref __binding_0, variant_index: ref __binding_1 } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
97pub struct PlaceTy<'tcx> {
98 pub ty: Ty<'tcx>,
99 pub variant_index: Option<VariantIdx>,
101}
102
103#[cfg(target_pointer_width = "64")]
105const _: [(); 16] = [(); ::std::mem::size_of::<PlaceTy<'_>>()];rustc_data_structures::static_assert_size!(PlaceTy<'_>, 16);
106
107impl<'tcx> PlaceTy<'tcx> {
108 #[inline]
109 pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {
110 PlaceTy { ty, variant_index: None }
111 }
112
113 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("field_ty",
"rustc_middle::mir::statement", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/cea272fa356e94bd2ee2cadf376630aa0683867a/compiler/rustc_middle/src/mir/statement.rs"),
::tracing_core::__macro_support::Option::Some(120u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::mir::statement"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("self_ty")
}> =
::tracing::__macro_support::FieldName::new("self_ty");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("variant_idx")
}> =
::tracing::__macro_support::FieldName::new("variant_idx");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("f")
}> =
::tracing::__macro_support::FieldName::new("f");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&variant_idx)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&f)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Unnormalized<'tcx, Ty<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
if let Some(variant_index) = variant_idx {
match *self_ty.kind() {
ty::Adt(adt_def, args) if adt_def.is_enum() => {
adt_def.variant(variant_index).fields[f].ty(tcx, args)
}
ty::Coroutine(def_id, args) => {
let mut variants =
args.as_coroutine().state_tys(def_id, tcx);
let Some(mut variant) =
variants.nth(variant_index.into()) else {
crate::util::bug::bug_fmt(format_args!("variant {0:?} of coroutine out of range: {1:?}",
variant_index, self_ty));
};
Unnormalized::new_wip(variant.nth(f.index()).unwrap_or_else(||
{
crate::util::bug::bug_fmt(format_args!("field {0:?} out of range of variant: {1:?} {2:?}",
f, self_ty, variant_idx))
}))
}
_ =>
crate::util::bug::bug_fmt(format_args!("can\'t downcast non-adt non-coroutine type: {0:?}",
self_ty)),
}
} else {
match self_ty.kind() {
ty::Adt(adt_def, args) if !adt_def.is_enum() => {
adt_def.non_enum_variant().fields[f].ty(tcx, args)
}
ty::Closure(_, args) =>
Unnormalized::dummy(args.as_closure().upvar_tys().get(f.index()).copied().unwrap_or_else(||
crate::util::bug::bug_fmt(format_args!("field {0:?} out of range: {1:?}",
f, self_ty)))),
ty::CoroutineClosure(_, args) =>
Unnormalized::dummy(args.as_coroutine_closure().upvar_tys().get(f.index()).copied().unwrap_or_else(||
crate::util::bug::bug_fmt(format_args!("field {0:?} out of range: {1:?}",
f, self_ty)))),
ty::Coroutine(_, args) =>
Unnormalized::dummy(args.as_coroutine().upvar_tys().get(f.index()).copied().unwrap_or_else(||
{
crate::util::bug::bug_fmt(format_args!("field {0:?} out of range of prefixes for {1}",
f, self_ty))
})),
ty::Tuple(tys) =>
Unnormalized::dummy(tys.get(f.index()).copied().unwrap_or_else(||
crate::util::bug::bug_fmt(format_args!("field {0:?} out of range: {1:?}",
f, self_ty)))),
_ =>
crate::util::bug::bug_fmt(format_args!("can\'t project out of {0:?}",
self_ty)),
}
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/cea272fa356e94bd2ee2cadf376630aa0683867a/compiler/rustc_middle/src/mir/statement.rs:120",
"rustc_middle::mir::statement", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/cea272fa356e94bd2ee2cadf376630aa0683867a/compiler/rustc_middle/src/mir/statement.rs"),
::tracing_core::__macro_support::Option::Some(120u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::mir::statement"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::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};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(tcx), ret)]
121 pub fn field_ty(
122 tcx: TyCtxt<'tcx>,
123 self_ty: Ty<'tcx>,
124 variant_idx: Option<VariantIdx>,
125 f: FieldIdx,
126 ) -> Unnormalized<'tcx, Ty<'tcx>> {
127 if let Some(variant_index) = variant_idx {
128 match *self_ty.kind() {
129 ty::Adt(adt_def, args) if adt_def.is_enum() => {
130 adt_def.variant(variant_index).fields[f].ty(tcx, args)
131 }
132 ty::Coroutine(def_id, args) => {
133 let mut variants = args.as_coroutine().state_tys(def_id, tcx);
134 let Some(mut variant) = variants.nth(variant_index.into()) else {
135 bug!("variant {variant_index:?} of coroutine out of range: {self_ty:?}");
136 };
137
138 Unnormalized::new_wip(variant.nth(f.index()).unwrap_or_else(|| {
139 bug!("field {f:?} out of range of variant: {self_ty:?} {variant_idx:?}")
140 }))
141 }
142 _ => bug!("can't downcast non-adt non-coroutine type: {self_ty:?}"),
143 }
144 } else {
145 match self_ty.kind() {
146 ty::Adt(adt_def, args) if !adt_def.is_enum() => {
147 adt_def.non_enum_variant().fields[f].ty(tcx, args)
148 }
149 ty::Closure(_, args) => Unnormalized::dummy(
150 args.as_closure()
151 .upvar_tys()
152 .get(f.index())
153 .copied()
154 .unwrap_or_else(|| bug!("field {f:?} out of range: {self_ty:?}")),
155 ),
156 ty::CoroutineClosure(_, args) => Unnormalized::dummy(
157 args.as_coroutine_closure()
158 .upvar_tys()
159 .get(f.index())
160 .copied()
161 .unwrap_or_else(|| bug!("field {f:?} out of range: {self_ty:?}")),
162 ),
163 ty::Coroutine(_, args) => Unnormalized::dummy(
165 args.as_coroutine().upvar_tys().get(f.index()).copied().unwrap_or_else(|| {
166 bug!("field {f:?} out of range of prefixes for {self_ty}")
167 }),
168 ),
169 ty::Tuple(tys) => Unnormalized::dummy(
170 tys.get(f.index())
171 .copied()
172 .unwrap_or_else(|| bug!("field {f:?} out of range: {self_ty:?}")),
173 ),
174 _ => bug!("can't project out of {self_ty:?}"),
175 }
176 }
177 }
178
179 pub fn multi_projection_ty(
180 self,
181 tcx: TyCtxt<'tcx>,
182 elems: &[PlaceElem<'tcx>],
183 ) -> PlaceTy<'tcx> {
184 elems.iter().fold(self, |place_ty, &elem| place_ty.projection_ty(tcx, elem))
185 }
186
187 pub fn projection_ty<V: Debug>(
191 self,
192 tcx: TyCtxt<'tcx>,
193 elem: ProjectionElem<V, Ty<'tcx>>,
194 ) -> PlaceTy<'tcx> {
195 self.projection_ty_core(tcx, &elem, |_, _, _, ty| ty, |ty| ty)
196 }
197
198 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("projection_ty_core",
"rustc_middle::mir::statement", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/cea272fa356e94bd2ee2cadf376630aa0683867a/compiler/rustc_middle/src/mir/statement.rs"),
::tracing_core::__macro_support::Option::Some(203u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::mir::statement"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("self")
}> =
::tracing::__macro_support::FieldName::new("self");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("elem")
}> =
::tracing::__macro_support::FieldName::new("elem");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&elem)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: PlaceTy<'tcx> = loop {};
return __tracing_attr_fake_return;
}
{
if self.variant_index.is_some() &&
!#[allow(non_exhaustive_omitted_patterns)] match elem {
ProjectionElem::Field(..) => true,
_ => false,
} {
crate::util::bug::bug_fmt(format_args!("cannot use non field projection on downcasted place"))
}
match *elem {
ProjectionElem::Deref => {
let ty =
self.ty.builtin_deref(true).unwrap_or_else(||
{
crate::util::bug::bug_fmt(format_args!("deref projection of non-dereferenceable ty {0:?}",
self))
});
PlaceTy::from_ty(ty)
}
ProjectionElem::PhantomDeref => PlaceTy::from_ty(self.ty),
ProjectionElem::Index(_) | ProjectionElem::ConstantIndex {
.. } => {
PlaceTy::from_ty(self.ty.builtin_index().unwrap())
}
ProjectionElem::Subslice { from, to, from_end } => {
PlaceTy::from_ty(match self.ty.kind() {
ty::Slice(..) => self.ty,
ty::Array(inner, _) if !from_end =>
Ty::new_array(tcx, *inner, to - from),
ty::Array(inner, size) if from_end => {
let size =
size.try_to_target_usize(tcx).expect("expected subslice projection on fixed-size array");
let len = size - from - to;
Ty::new_array(tcx, *inner, len)
}
_ =>
crate::util::bug::bug_fmt(format_args!("cannot subslice non-array type: `{0:?}`",
self)),
})
}
ProjectionElem::Downcast(_name, index) => {
PlaceTy { ty: self.ty, variant_index: Some(index) }
}
ProjectionElem::Field(f, fty) => {
PlaceTy::from_ty(handle_field(self.ty, self.variant_index,
f, fty))
}
ProjectionElem::OpaqueCast(ty) =>
PlaceTy::from_ty(handle_opaque_cast_and_subtype(ty)),
ProjectionElem::UnwrapUnsafeBinder(ty) => {
PlaceTy::from_ty(handle_opaque_cast_and_subtype(ty))
}
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/cea272fa356e94bd2ee2cadf376630aa0683867a/compiler/rustc_middle/src/mir/statement.rs:203",
"rustc_middle::mir::statement", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/cea272fa356e94bd2ee2cadf376630aa0683867a/compiler/rustc_middle/src/mir/statement.rs"),
::tracing_core::__macro_support::Option::Some(203u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::mir::statement"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::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};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(tcx, handle_field, handle_opaque_cast_and_subtype), ret)]
204 pub fn projection_ty_core<V, T>(
205 self,
206 tcx: TyCtxt<'tcx>,
207 elem: &ProjectionElem<V, T>,
208 mut handle_field: impl FnMut(Ty<'tcx>, Option<VariantIdx>, FieldIdx, T) -> Ty<'tcx>,
209 mut handle_opaque_cast_and_subtype: impl FnMut(T) -> Ty<'tcx>,
210 ) -> PlaceTy<'tcx>
211 where
212 V: Debug,
213 T: Debug + Copy,
214 {
215 if self.variant_index.is_some() && !matches!(elem, ProjectionElem::Field(..)) {
216 bug!("cannot use non field projection on downcasted place")
217 }
218 match *elem {
219 ProjectionElem::Deref => {
220 let ty = self.ty.builtin_deref(true).unwrap_or_else(|| {
221 bug!("deref projection of non-dereferenceable ty {:?}", self)
222 });
223 PlaceTy::from_ty(ty)
224 }
225 ProjectionElem::PhantomDeref => PlaceTy::from_ty(self.ty),
226 ProjectionElem::Index(_) | ProjectionElem::ConstantIndex { .. } => {
227 PlaceTy::from_ty(self.ty.builtin_index().unwrap())
228 }
229 ProjectionElem::Subslice { from, to, from_end } => {
230 PlaceTy::from_ty(match self.ty.kind() {
231 ty::Slice(..) => self.ty,
232 ty::Array(inner, _) if !from_end => Ty::new_array(tcx, *inner, to - from),
233 ty::Array(inner, size) if from_end => {
234 let size = size
235 .try_to_target_usize(tcx)
236 .expect("expected subslice projection on fixed-size array");
237 let len = size - from - to;
238 Ty::new_array(tcx, *inner, len)
239 }
240 _ => bug!("cannot subslice non-array type: `{:?}`", self),
241 })
242 }
243 ProjectionElem::Downcast(_name, index) => {
244 PlaceTy { ty: self.ty, variant_index: Some(index) }
245 }
246 ProjectionElem::Field(f, fty) => {
247 PlaceTy::from_ty(handle_field(self.ty, self.variant_index, f, fty))
248 }
249 ProjectionElem::OpaqueCast(ty) => PlaceTy::from_ty(handle_opaque_cast_and_subtype(ty)),
250
251 ProjectionElem::UnwrapUnsafeBinder(ty) => {
253 PlaceTy::from_ty(handle_opaque_cast_and_subtype(ty))
254 }
255 }
256 }
257}
258
259impl<V, T> ProjectionElem<V, T> {
260 pub fn is_indirect(&self) -> bool {
263 match self {
264 Self::Deref | Self::PhantomDeref => true,
265
266 Self::Field(_, _)
267 | Self::Index(_)
268 | Self::OpaqueCast(_)
269 | Self::ConstantIndex { .. }
270 | Self::Subslice { .. }
271 | Self::Downcast(_, _)
272 | Self::UnwrapUnsafeBinder(..) => false,
273 }
274 }
275
276 pub fn is_stable_offset(&self) -> bool {
279 match self {
280 Self::Deref | Self::Index(_) => false,
281 Self::Field(_, _)
282 | Self::OpaqueCast(_)
283 | Self::ConstantIndex { .. }
284 | Self::Subslice { .. }
285 | Self::Downcast(_, _)
286 | Self::UnwrapUnsafeBinder(..)
287 | Self::PhantomDeref => true,
288 }
289 }
290
291 pub fn is_downcast_to(&self, v: VariantIdx) -> bool {
293 #[allow(non_exhaustive_omitted_patterns)] match *self {
Self::Downcast(_, x) if x == v => true,
_ => false,
}matches!(*self, Self::Downcast(_, x) if x == v)
294 }
295
296 pub fn is_field_to(&self, f: FieldIdx) -> bool {
298 #[allow(non_exhaustive_omitted_patterns)] match *self {
Self::Field(x, _) if x == f => true,
_ => false,
}matches!(*self, Self::Field(x, _) if x == f)
299 }
300
301 pub fn can_use_in_debuginfo(&self) -> bool {
303 match self {
304 Self::ConstantIndex { from_end: false, .. }
305 | Self::Deref
306 | Self::Downcast(_, _)
307 | Self::Field(_, _) => true,
308 Self::ConstantIndex { from_end: true, .. }
309 | Self::Index(_)
310 | Self::OpaqueCast(_)
311 | Self::Subslice { .. }
312 | Self::PhantomDeref => false,
313
314 Self::UnwrapUnsafeBinder(..) => false,
316 }
317 }
318
319 pub fn kind(self) -> ProjectionKind {
321 self.try_map(|_| Some(()), |_| ()).unwrap()
322 }
323
324 pub fn try_map<V2, T2>(
326 self,
327 v: impl FnOnce(V) -> Option<V2>,
328 t: impl FnOnce(T) -> T2,
329 ) -> Option<ProjectionElem<V2, T2>> {
330 Some(match self {
331 ProjectionElem::Deref => ProjectionElem::Deref,
332 ProjectionElem::PhantomDeref => crate::util::bug::bug_fmt(format_args!("PhantomDeref shouldn\'t hopefully come here"))bug!("PhantomDeref shouldn't hopefully come here"),
333 ProjectionElem::Downcast(name, read_variant) => {
334 ProjectionElem::Downcast(name, read_variant)
335 }
336 ProjectionElem::Field(f, ty) => ProjectionElem::Field(f, t(ty)),
337 ProjectionElem::ConstantIndex { offset, min_length, from_end } => {
338 ProjectionElem::ConstantIndex { offset, min_length, from_end }
339 }
340 ProjectionElem::Subslice { from, to, from_end } => {
341 ProjectionElem::Subslice { from, to, from_end }
342 }
343 ProjectionElem::OpaqueCast(ty) => ProjectionElem::OpaqueCast(t(ty)),
344 ProjectionElem::UnwrapUnsafeBinder(ty) => ProjectionElem::UnwrapUnsafeBinder(t(ty)),
345 ProjectionElem::Index(val) => ProjectionElem::Index(v(val)?),
346 })
347 }
348}
349
350pub type ProjectionKind = ProjectionElem<(), ()>;
353
354#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl<'tcx> ::core::clone::TrivialClone for PlaceRef<'tcx> { }
#[automatically_derived]
impl<'tcx> ::core::clone::Clone for PlaceRef<'tcx> {
#[inline]
fn clone(&self) -> PlaceRef<'tcx> {
let _: ::core::clone::AssertParamIsClone<Local>;
let _: ::core::clone::AssertParamIsClone<&'tcx [PlaceElem<'tcx>]>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for PlaceRef<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::marker::StructuralPartialEq for PlaceRef<'tcx> { }
#[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for PlaceRef<'tcx> {
#[inline]
fn eq(&self, other: &PlaceRef<'tcx>) -> bool {
self.local == other.local && self.projection == other.projection
}
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for PlaceRef<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Local>;
let _: ::core::cmp::AssertParamIsEq<&'tcx [PlaceElem<'tcx>]>;
}
}Eq, #[automatically_derived]
impl<'tcx> ::core::hash::Hash for PlaceRef<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.local, state);
::core::hash::Hash::hash(&self.projection, state)
}
}Hash)]
355pub struct PlaceRef<'tcx> {
356 pub local: Local,
357 pub projection: &'tcx [PlaceElem<'tcx>],
358}
359
360impl<'tcx> !PartialOrd for PlaceRef<'tcx> {}
365
366impl<'tcx> Place<'tcx> {
367 pub fn return_place() -> Place<'tcx> {
369 Place { local: RETURN_PLACE, projection: List::empty() }
370 }
371
372 pub fn is_indirect(&self) -> bool {
377 self.projection.iter().any(|elem| elem.is_indirect())
378 }
379
380 pub fn is_stable_offset(&self) -> bool {
383 self.projection.iter().all(|elem| elem.is_stable_offset())
384 }
385
386 pub fn is_indirect_first_projection(&self) -> bool {
392 self.as_ref().is_indirect_first_projection()
393 }
394
395 #[inline(always)]
398 pub fn local_or_deref_local(&self) -> Option<Local> {
399 self.as_ref().local_or_deref_local()
400 }
401
402 #[inline(always)]
405 pub fn as_local(&self) -> Option<Local> {
406 self.as_ref().as_local()
407 }
408
409 #[inline]
410 pub fn as_ref(&self) -> PlaceRef<'tcx> {
411 PlaceRef { local: self.local, projection: self.projection }
412 }
413
414 #[inline]
422 pub fn iter_projections(
423 self,
424 ) -> impl Iterator<Item = (PlaceRef<'tcx>, PlaceElem<'tcx>)> + DoubleEndedIterator {
425 self.as_ref().iter_projections()
426 }
427
428 pub fn project_deeper(self, more_projections: &[PlaceElem<'tcx>], tcx: TyCtxt<'tcx>) -> Self {
431 if more_projections.is_empty() {
432 return self;
433 }
434
435 self.as_ref().project_deeper(more_projections, tcx)
436 }
437
438 pub fn project_to_field(
442 self,
443 idx: FieldIdx,
444 local_decls: &(impl HasLocalDecls<'tcx> + ?Sized),
445 tcx: TyCtxt<'tcx>,
446 ) -> Self {
447 let ty = self.ty(local_decls, tcx).ty;
448 let ty::Adt(adt, args) = ty.kind() else { {
::core::panicking::panic_fmt(format_args!("projecting to field of non-ADT {0}",
ty));
}panic!("projecting to field of non-ADT {ty}") };
449 let field = &adt.non_enum_variant().fields[idx];
450 let field_ty = field.ty(tcx, args).skip_norm_wip();
451 self.project_deeper(&[ProjectionElem::Field(idx, field_ty)], tcx)
452 }
453
454 pub fn ty_from<D>(
455 local: Local,
456 projection: &[PlaceElem<'tcx>],
457 local_decls: &D,
458 tcx: TyCtxt<'tcx>,
459 ) -> PlaceTy<'tcx>
460 where
461 D: ?Sized + HasLocalDecls<'tcx>,
462 {
463 PlaceTy::from_ty(local_decls.local_decls()[local].ty).multi_projection_ty(tcx, projection)
466 }
467
468 pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
469 where
470 D: HasLocalDecls<'tcx>,
471 {
472 Place::ty_from(self.local, self.projection, local_decls, tcx)
473 }
474}
475
476impl From<Local> for Place<'_> {
477 #[inline]
478 fn from(local: Local) -> Self {
479 Place { local, projection: List::empty() }
480 }
481}
482
483impl<'tcx> PlaceRef<'tcx> {
484 pub fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool {
485 self.local == other.local
486 && self.projection.len() <= other.projection.len()
487 && self.projection == &other.projection[..self.projection.len()]
488 }
489
490 pub fn local_or_deref_local(&self) -> Option<Local> {
493 match *self {
494 PlaceRef { local, projection: [] }
495 | PlaceRef {
496 local,
497 projection: [ProjectionElem::Deref | ProjectionElem::PhantomDeref],
498 } => Some(local),
499 _ => None,
500 }
501 }
502
503 pub fn is_indirect(&self) -> bool {
508 self.projection.iter().any(|elem| elem.is_indirect())
509 }
510
511 pub fn is_indirect_first_projection(&self) -> bool {
517 if true {
if !(self.projection.is_empty() ||
!self.projection[1..].contains(&PlaceElem::Deref)) {
::core::panicking::panic("assertion failed: self.projection.is_empty() ||\n !self.projection[1..].contains(&PlaceElem::Deref)")
};
};debug_assert!(
519 self.projection.is_empty() || !self.projection[1..].contains(&PlaceElem::Deref)
520 );
521 self.projection.first() == Some(&PlaceElem::Deref)
522 }
523
524 #[inline]
527 pub fn as_local(&self) -> Option<Local> {
528 match *self {
529 PlaceRef { local, projection: [] } => Some(local),
530 _ => None,
531 }
532 }
533
534 #[inline]
535 pub fn to_place(&self, tcx: TyCtxt<'tcx>) -> Place<'tcx> {
536 Place { local: self.local, projection: tcx.mk_place_elems(self.projection) }
537 }
538
539 #[inline]
540 pub fn last_projection(&self) -> Option<(PlaceRef<'tcx>, PlaceElem<'tcx>)> {
541 if let &[ref proj_base @ .., elem] = self.projection {
542 Some((PlaceRef { local: self.local, projection: proj_base }, elem))
543 } else {
544 None
545 }
546 }
547
548 #[inline]
556 pub fn iter_projections(
557 self,
558 ) -> impl Iterator<Item = (PlaceRef<'tcx>, PlaceElem<'tcx>)> + DoubleEndedIterator {
559 self.projection.iter().enumerate().map(move |(i, proj)| {
560 let base = PlaceRef { local: self.local, projection: &self.projection[..i] };
561 (base, *proj)
562 })
563 }
564
565 pub fn accessed_locals(self) -> impl Iterator<Item = Local> {
567 std::iter::once(self.local).chain(self.projection.iter().filter_map(|proj| match proj {
568 ProjectionElem::Index(local) => Some(*local),
569 ProjectionElem::Deref
570 | ProjectionElem::PhantomDeref
571 | ProjectionElem::Field(_, _)
572 | ProjectionElem::ConstantIndex { .. }
573 | ProjectionElem::Subslice { .. }
574 | ProjectionElem::Downcast(_, _)
575 | ProjectionElem::OpaqueCast(_)
576 | ProjectionElem::UnwrapUnsafeBinder(_) => None,
577 }))
578 }
579
580 pub fn project_deeper(
583 self,
584 more_projections: &[PlaceElem<'tcx>],
585 tcx: TyCtxt<'tcx>,
586 ) -> Place<'tcx> {
587 let mut v: Vec<PlaceElem<'tcx>>;
588
589 let new_projections = if self.projection.is_empty() {
590 more_projections
591 } else {
592 v = Vec::with_capacity(self.projection.len() + more_projections.len());
593 v.extend(self.projection);
594 v.extend(more_projections);
595 &v
596 };
597
598 Place { local: self.local, projection: tcx.mk_place_elems(new_projections) }
599 }
600
601 pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
602 where
603 D: ?Sized + HasLocalDecls<'tcx>,
604 {
605 Place::ty_from(self.local, self.projection, local_decls, tcx)
606 }
607}
608
609impl From<Local> for PlaceRef<'_> {
610 #[inline]
611 fn from(local: Local) -> Self {
612 PlaceRef { local, projection: &[] }
613 }
614}
615
616impl<'tcx> Operand<'tcx> {
620 pub fn function_handle(
624 tcx: TyCtxt<'tcx>,
625 def_id: DefId,
626 args: &[GenericArg<'tcx>],
627 span: Span,
628 ) -> Self {
629 Operand::zero_sized_constant(
630 tcx.type_of(def_id).instantiate(tcx, args).skip_norm_wip(),
631 span,
632 )
633 }
634
635 pub fn unevaluated_constant(
638 tcx: TyCtxt<'tcx>,
639 def_id: DefId,
640 args: &[GenericArg<'tcx>],
641 span: Span,
642 ) -> Self {
643 let const_ = Const::from_unevaluated(tcx, def_id).instantiate(tcx, args).skip_norm_wip();
644 Operand::Constant(Box::new(ConstOperand { span, user_ty: None, const_ }))
645 }
646
647 pub fn zero_sized_constant(ty: Ty<'tcx>, span: Span) -> Self {
649 let const_ = Const::Val(ConstValue::ZeroSized, ty);
650 Operand::Constant(Box::new(ConstOperand { span, user_ty: None, const_ }))
651 }
652
653 pub fn is_move(&self) -> bool {
654 #[allow(non_exhaustive_omitted_patterns)] match self {
Operand::Move(..) => true,
_ => false,
}matches!(self, Operand::Move(..))
655 }
656
657 pub fn const_from_scalar(
660 tcx: TyCtxt<'tcx>,
661 ty: Ty<'tcx>,
662 val: Scalar,
663 span: Span,
664 ) -> Operand<'tcx> {
665 if true {
if !{
let typing_env = ty::TypingEnv::fully_monomorphized();
let type_size =
tcx.layout_of(typing_env.as_query_input(ty)).unwrap_or_else(|e|
{
::core::panicking::panic_fmt(format_args!("could not compute layout for {0:?}: {1:?}",
ty, e));
}).size;
let scalar_size =
match val {
Scalar::Int(int) => int.size(),
_ => {
::core::panicking::panic_fmt(format_args!("Invalid scalar type {0:?}",
val));
}
};
scalar_size == type_size
} {
::core::panicking::panic("assertion failed: {\n let typing_env = ty::TypingEnv::fully_monomorphized();\n let type_size =\n tcx.layout_of(typing_env.as_query_input(ty)).unwrap_or_else(|e|\n panic!(\"could not compute layout for {ty:?}: {e:?}\")).size;\n let scalar_size =\n match val {\n Scalar::Int(int) => int.size(),\n _ => panic!(\"Invalid scalar type {val:?}\"),\n };\n scalar_size == type_size\n}")
};
};debug_assert!({
666 let typing_env = ty::TypingEnv::fully_monomorphized();
667 let type_size = tcx
668 .layout_of(typing_env.as_query_input(ty))
669 .unwrap_or_else(|e| panic!("could not compute layout for {ty:?}: {e:?}"))
670 .size;
671 let scalar_size = match val {
672 Scalar::Int(int) => int.size(),
673 _ => panic!("Invalid scalar type {val:?}"),
674 };
675 scalar_size == type_size
676 });
677 Operand::Constant(Box::new(ConstOperand {
678 span,
679 user_ty: None,
680 const_: Const::Val(ConstValue::Scalar(val), ty),
681 }))
682 }
683
684 pub fn to_copy(&self) -> Self {
685 match *self {
686 Operand::Copy(_) | Operand::Constant(_) | Operand::RuntimeChecks(_) => self.clone(),
687 Operand::Move(place) => Operand::Copy(place),
688 }
689 }
690
691 pub fn place(&self) -> Option<Place<'tcx>> {
694 match self {
695 Operand::Copy(place) | Operand::Move(place) => Some(*place),
696 Operand::Constant(_) | Operand::RuntimeChecks(_) => None,
697 }
698 }
699
700 pub fn constant(&self) -> Option<&ConstOperand<'tcx>> {
703 match self {
704 Operand::Constant(x) => Some(&**x),
705 Operand::Copy(_) | Operand::Move(_) | Operand::RuntimeChecks(_) => None,
706 }
707 }
708
709 pub fn const_fn_def(&self) -> Option<(DefId, GenericArgsRef<'tcx>)> {
714 let const_ty = self.constant()?.const_.ty();
715 if let ty::FnDef(def_id, args) = *const_ty.kind() {
716 Some((def_id, args.no_bound_vars().unwrap()))
717 } else {
718 None
719 }
720 }
721
722 pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
723 where
724 D: ?Sized + HasLocalDecls<'tcx>,
725 {
726 match self {
727 &Operand::Copy(ref l) | &Operand::Move(ref l) => l.ty(local_decls, tcx).ty,
728 Operand::Constant(c) => c.const_.ty(),
729 Operand::RuntimeChecks(_) => tcx.types.bool,
730 }
731 }
732
733 pub fn span<D>(&self, local_decls: &D) -> Span
734 where
735 D: ?Sized + HasLocalDecls<'tcx>,
736 {
737 match self {
738 &Operand::Copy(ref l) | &Operand::Move(ref l) => {
739 local_decls.local_decls()[l.local].source_info.span
740 }
741 Operand::Constant(c) => c.span,
742 Operand::RuntimeChecks(_) => DUMMY_SP,
744 }
745 }
746}
747
748impl<'tcx> ConstOperand<'tcx> {
749 pub fn check_static_ptr(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
750 match self.const_.try_to_scalar() {
751 Some(Scalar::Ptr(ptr, _size)) => match tcx.global_alloc(ptr.provenance.alloc_id()) {
752 GlobalAlloc::Static(def_id) => {
753 if !!tcx.is_thread_local_static(def_id) {
::core::panicking::panic("assertion failed: !tcx.is_thread_local_static(def_id)")
};assert!(!tcx.is_thread_local_static(def_id));
754 Some(def_id)
755 }
756 _ => None,
757 },
758 _ => None,
759 }
760 }
761
762 #[inline]
763 pub fn ty(&self) -> Ty<'tcx> {
764 self.const_.ty()
765 }
766}
767
768impl<'tcx> Rvalue<'tcx> {
772 #[inline]
774 pub fn is_safe_to_remove(&self) -> bool {
775 match self {
776 Rvalue::Cast(CastKind::PointerExposeProvenance, _, _) => false,
780
781 Rvalue::Use(_, _)
782 | Rvalue::CopyForDeref(_)
783 | Rvalue::Repeat(_, _)
784 | Rvalue::Ref(_, _, _)
785 | Rvalue::Reborrow(_, _, _)
786 | Rvalue::ThreadLocalRef(_)
787 | Rvalue::RawPtr(_, _)
788 | Rvalue::Cast(
789 CastKind::IntToInt
790 | CastKind::FloatToInt
791 | CastKind::FloatToFloat
792 | CastKind::IntToFloat
793 | CastKind::FnPtrToPtr
794 | CastKind::PtrToPtr
795 | CastKind::PointerCoercion(_, _)
796 | CastKind::PointerWithExposedProvenance
797 | CastKind::Transmute
798 | CastKind::BoxDerefTransmute
799 | CastKind::Subtype,
800 _,
801 _,
802 )
803 | Rvalue::BinaryOp(_, _)
804 | Rvalue::UnaryOp(_, _)
805 | Rvalue::Discriminant(_)
806 | Rvalue::Aggregate(_, _)
807 | Rvalue::WrapUnsafeBinder(_, _) => true,
808 }
809 }
810
811 pub fn is_generic_reborrow(&self) -> bool {
814 #[allow(non_exhaustive_omitted_patterns)] match self {
Self::Reborrow(..) => true,
_ => false,
}matches!(self, Self::Reborrow(..))
815 }
816
817 pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
818 where
819 D: ?Sized + HasLocalDecls<'tcx>,
820 {
821 match *self {
822 Rvalue::Use(ref operand, _) => operand.ty(local_decls, tcx),
823 Rvalue::Repeat(ref operand, count) => {
824 Ty::new_array_with_const_len(tcx, operand.ty(local_decls, tcx), count)
825 }
826 Rvalue::ThreadLocalRef(did) => tcx.thread_local_ptr_ty(did),
827 Rvalue::Ref(reg, bk, ref place) => {
828 let place_ty = place.ty(local_decls, tcx).ty;
829 Ty::new_ref(tcx, reg, place_ty, bk.to_mutbl_lossy())
830 }
831 Rvalue::Reborrow(target, _, _) => target,
832 Rvalue::RawPtr(kind, ref place) => {
833 let place_ty = place.ty(local_decls, tcx).ty;
834 Ty::new_ptr(tcx, place_ty, kind.to_mutbl_lossy())
835 }
836 Rvalue::Cast(.., ty) => ty,
837 Rvalue::BinaryOp(op, (ref lhs, ref rhs)) => {
838 let lhs_ty = lhs.ty(local_decls, tcx);
839 let rhs_ty = rhs.ty(local_decls, tcx);
840 op.ty(tcx, lhs_ty, rhs_ty)
841 }
842 Rvalue::UnaryOp(op, ref operand) => {
843 let arg_ty = operand.ty(local_decls, tcx);
844 op.ty(tcx, arg_ty)
845 }
846 Rvalue::Discriminant(ref place) => place.ty(local_decls, tcx).ty.discriminant_ty(tcx),
847 Rvalue::Aggregate(ref ak, ref ops) => match **ak {
848 AggregateKind::Array(ty) => Ty::new_array(tcx, ty, ops.len() as u64),
849 AggregateKind::Tuple => {
850 Ty::new_tup_from_iter(tcx, ops.iter().map(|op| op.ty(local_decls, tcx)))
851 }
852 AggregateKind::Adt(did, _, args, _, _) => {
853 tcx.type_of(did).instantiate(tcx, args).skip_norm_wip()
854 }
855 AggregateKind::Closure(did, args) => Ty::new_closure(tcx, did, args),
856 AggregateKind::Coroutine(did, args) => Ty::new_coroutine(tcx, did, args),
857 AggregateKind::CoroutineClosure(did, args) => {
858 Ty::new_coroutine_closure(tcx, did, args)
859 }
860 AggregateKind::RawPtr(ty, mutability) => Ty::new_ptr(tcx, ty, mutability),
861 },
862 Rvalue::CopyForDeref(ref place) => place.ty(local_decls, tcx).ty,
863 Rvalue::WrapUnsafeBinder(_, ty) => ty,
864 }
865 }
866}
867
868impl BorrowKind {
869 pub fn mutability(&self) -> Mutability {
870 match *self {
871 BorrowKind::Shared | BorrowKind::Fake(_) => Mutability::Not,
872 BorrowKind::Mut { .. } => Mutability::Mut,
873 }
874 }
875
876 pub fn is_two_phase_borrow(&self) -> bool {
879 match *self {
880 BorrowKind::Shared
881 | BorrowKind::Fake(_)
882 | BorrowKind::Mut { kind: MutBorrowKind::Default | MutBorrowKind::ClosureCapture } => {
883 false
884 }
885 BorrowKind::Mut { kind: MutBorrowKind::TwoPhaseBorrow } => true,
886 }
887 }
888
889 pub fn to_mutbl_lossy(self) -> hir::Mutability {
890 match self {
891 BorrowKind::Mut { .. } => hir::Mutability::Mut,
892 BorrowKind::Shared => hir::Mutability::Not,
893
894 BorrowKind::Fake(_) => hir::Mutability::Not,
897 }
898 }
899}
900
901impl<'tcx> UnOp {
902 pub fn ty(&self, tcx: TyCtxt<'tcx>, arg_ty: Ty<'tcx>) -> Ty<'tcx> {
903 match self {
904 UnOp::Not | UnOp::Neg => arg_ty,
905 UnOp::PtrMetadata => arg_ty.pointee_metadata_ty_or_projection(tcx),
906 }
907 }
908}
909
910impl<'tcx> BinOp {
911 pub fn ty(&self, tcx: TyCtxt<'tcx>, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>) -> Ty<'tcx> {
912 match self {
914 &BinOp::Add
915 | &BinOp::AddUnchecked
916 | &BinOp::Sub
917 | &BinOp::SubUnchecked
918 | &BinOp::Mul
919 | &BinOp::MulUnchecked
920 | &BinOp::Div
921 | &BinOp::Rem
922 | &BinOp::BitXor
923 | &BinOp::BitAnd
924 | &BinOp::BitOr => {
925 {
match (&lhs_ty, &rhs_ty) {
(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);
}
}
}
};assert_eq!(lhs_ty, rhs_ty);
927 lhs_ty
928 }
929 &BinOp::AddWithOverflow | &BinOp::SubWithOverflow | &BinOp::MulWithOverflow => {
930 {
match (&lhs_ty, &rhs_ty) {
(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);
}
}
}
};assert_eq!(lhs_ty, rhs_ty);
932 Ty::new_tup(tcx, &[lhs_ty, tcx.types.bool])
933 }
934 &BinOp::Shl
935 | &BinOp::ShlUnchecked
936 | &BinOp::Shr
937 | &BinOp::ShrUnchecked
938 | &BinOp::Offset => {
939 lhs_ty }
941 &BinOp::Eq | &BinOp::Lt | &BinOp::Le | &BinOp::Ne | &BinOp::Ge | &BinOp::Gt => {
942 tcx.types.bool
943 }
944 &BinOp::Cmp => {
945 {
match (&lhs_ty, &rhs_ty) {
(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);
}
}
}
};assert_eq!(lhs_ty, rhs_ty);
947 tcx.ty_ordering_enum(DUMMY_SP)
948 }
949 }
950 }
951 pub(crate) fn to_hir_binop(self) -> hir::BinOpKind {
952 match self {
953 BinOp::Add | BinOp::AddWithOverflow => hir::BinOpKind::Add,
956 BinOp::Sub | BinOp::SubWithOverflow => hir::BinOpKind::Sub,
957 BinOp::Mul | BinOp::MulWithOverflow => hir::BinOpKind::Mul,
958 BinOp::Div => hir::BinOpKind::Div,
959 BinOp::Rem => hir::BinOpKind::Rem,
960 BinOp::BitXor => hir::BinOpKind::BitXor,
961 BinOp::BitAnd => hir::BinOpKind::BitAnd,
962 BinOp::BitOr => hir::BinOpKind::BitOr,
963 BinOp::Shl => hir::BinOpKind::Shl,
964 BinOp::Shr => hir::BinOpKind::Shr,
965 BinOp::Eq => hir::BinOpKind::Eq,
966 BinOp::Ne => hir::BinOpKind::Ne,
967 BinOp::Lt => hir::BinOpKind::Lt,
968 BinOp::Gt => hir::BinOpKind::Gt,
969 BinOp::Le => hir::BinOpKind::Le,
970 BinOp::Ge => hir::BinOpKind::Ge,
971 BinOp::Cmp
973 | BinOp::AddUnchecked
974 | BinOp::SubUnchecked
975 | BinOp::MulUnchecked
976 | BinOp::ShlUnchecked
977 | BinOp::ShrUnchecked
978 | BinOp::Offset => {
979 ::core::panicking::panic("internal error: entered unreachable code")unreachable!()
980 }
981 }
982 }
983
984 pub fn overflowing_to_wrapping(self) -> Option<BinOp> {
986 Some(match self {
987 BinOp::AddWithOverflow => BinOp::Add,
988 BinOp::SubWithOverflow => BinOp::Sub,
989 BinOp::MulWithOverflow => BinOp::Mul,
990 _ => return None,
991 })
992 }
993
994 pub fn is_overflowing(self) -> bool {
996 self.overflowing_to_wrapping().is_some()
997 }
998
999 pub fn wrapping_to_overflowing(self) -> Option<BinOp> {
1001 Some(match self {
1002 BinOp::Add => BinOp::AddWithOverflow,
1003 BinOp::Sub => BinOp::SubWithOverflow,
1004 BinOp::Mul => BinOp::MulWithOverflow,
1005 _ => return None,
1006 })
1007 }
1008}
1009
1010impl From<Mutability> for RawPtrKind {
1011 fn from(other: Mutability) -> Self {
1012 match other {
1013 Mutability::Mut => RawPtrKind::Mut,
1014 Mutability::Not => RawPtrKind::Const,
1015 }
1016 }
1017}
1018
1019impl RawPtrKind {
1020 pub fn is_fake(self) -> bool {
1021 match self {
1022 RawPtrKind::Mut | RawPtrKind::Const => false,
1023 RawPtrKind::FakeForPtrMetadata => true,
1024 }
1025 }
1026
1027 pub fn to_mutbl_lossy(self) -> Mutability {
1028 match self {
1029 RawPtrKind::Mut => Mutability::Mut,
1030 RawPtrKind::Const => Mutability::Not,
1031
1032 RawPtrKind::FakeForPtrMetadata => Mutability::Not,
1035 }
1036 }
1037
1038 pub fn ptr_str(self) -> &'static str {
1039 match self {
1040 RawPtrKind::Mut => "mut",
1041 RawPtrKind::Const => "const",
1042 RawPtrKind::FakeForPtrMetadata => "const (fake)",
1043 }
1044 }
1045}
1046
1047#[derive(#[automatically_derived]
impl<'tcx> ::core::default::Default for StmtDebugInfos<'tcx> {
#[inline]
fn default() -> StmtDebugInfos<'tcx> {
StmtDebugInfos(::core::default::Default::default())
}
}Default, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for StmtDebugInfos<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "StmtDebugInfos",
&&self.0)
}
}Debug, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for StmtDebugInfos<'tcx> {
#[inline]
fn clone(&self) -> StmtDebugInfos<'tcx> {
StmtDebugInfos(::core::clone::Clone::clone(&self.0))
}
}Clone, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for StmtDebugInfos<'tcx> {
fn encode(&self, __encoder: &mut __E) {
let StmtDebugInfos(ref __binding_0) = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for StmtDebugInfos<'tcx> {
fn decode(__decoder: &mut __D) -> Self {
StmtDebugInfos(::rustc_serialize::Decodable::decode(__decoder))
}
}
};TyDecodable, const _: () =
{
impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
StmtDebugInfos<'tcx> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
StmtDebugInfos(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for StmtDebugInfos<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
StmtDebugInfos(__binding_0) => {
StmtDebugInfos(::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
StmtDebugInfos(__binding_0) => {
StmtDebugInfos(::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder))
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for StmtDebugInfos<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
StmtDebugInfos(ref __binding_0) => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
1055pub struct StmtDebugInfos<'tcx>(Option<ThinVec<StmtDebugInfo<'tcx>>>);
1056
1057impl<'tcx> StmtDebugInfos<'tcx> {
1058 pub fn push(&mut self, debuginfo: StmtDebugInfo<'tcx>) {
1059 self.0.get_or_insert_default().push(debuginfo);
1060 }
1061 #[inline]
1062 pub fn drop_debuginfo(&mut self) {
1063 match &mut self.0 {
1064 None => (),
1065 Some(v) => outline(move || v.clear()),
1066 }
1067 }
1068
1069 #[inline]
1070 pub fn is_empty(&self) -> bool {
1071 match &self.0 {
1072 None => true,
1073 Some(v) => outline(move || v.is_empty()),
1074 }
1075 }
1076 #[inline]
1077 pub fn prepend(&mut self, debuginfos: &mut Self) {
1078 if debuginfos.is_empty() {
1079 return;
1080 };
1081 outline(move || {
1082 debuginfos.append(self);
1083 std::mem::swap(debuginfos, self);
1084 })
1085 }
1086 #[inline]
1087 pub fn append(&mut self, debuginfos: &mut Self) {
1088 if debuginfos.is_empty() {
1089 return;
1090 };
1091 outline(move || self.0.get_or_insert_default().append(debuginfos.0.as_mut().unwrap()));
1092 }
1093 #[inline]
1094 pub fn extend(&mut self, debuginfos: &Self) {
1095 if debuginfos.is_empty() {
1096 return;
1097 };
1098 outline(move || self.0.get_or_insert_default().extend_from_slice(debuginfos.as_slice()))
1099 }
1100
1101 #[inline]
1102 pub fn as_slice(&self) -> &[StmtDebugInfo<'tcx>] {
1103 match &self.0 {
1104 None => &[],
1105 Some(items) => outline(move || items.as_slice()),
1106 }
1107 }
1108
1109 #[inline]
1110 pub fn as_mut_slice(&mut self) -> &mut [StmtDebugInfo<'tcx>] {
1111 match &mut self.0 {
1112 None => &mut [],
1113 Some(items) => outline(move || items.as_mut_slice()),
1114 }
1115 }
1116 #[inline]
1117 pub fn retain_locals(&mut self, locals: &DenseBitSet<Local>) {
1118 match &mut self.0 {
1119 None => (),
1120 Some(items) => outline(move || {
1121 items.retain(|debuginfo| match debuginfo {
1122 StmtDebugInfo::AssignRef(local, _) | StmtDebugInfo::InvalidAssign(local) => {
1123 locals.contains(*local)
1124 }
1125 })
1126 }),
1127 }
1128 }
1129}
1130
1131impl<'tcx> ops::Deref for StmtDebugInfos<'tcx> {
1132 type Target = [StmtDebugInfo<'tcx>];
1133
1134 #[inline]
1135 fn deref(&self) -> &Self::Target {
1136 self.as_slice()
1137 }
1138}
1139
1140impl<'tcx> ops::DerefMut for StmtDebugInfos<'tcx> {
1141 #[inline]
1142 fn deref_mut(&mut self) -> &mut Self::Target {
1143 self.as_mut_slice()
1144 }
1145}
1146
1147#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for StmtDebugInfo<'tcx> {
#[inline]
fn clone(&self) -> StmtDebugInfo<'tcx> {
match self {
StmtDebugInfo::AssignRef(__self_0, __self_1) =>
StmtDebugInfo::AssignRef(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
StmtDebugInfo::InvalidAssign(__self_0) =>
StmtDebugInfo::InvalidAssign(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for StmtDebugInfo<'tcx> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
StmtDebugInfo::AssignRef(ref __binding_0, ref __binding_1)
=> {
0usize
}
StmtDebugInfo::InvalidAssign(ref __binding_0) => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
StmtDebugInfo::AssignRef(ref __binding_0, ref __binding_1)
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
StmtDebugInfo::InvalidAssign(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for StmtDebugInfo<'tcx> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
StmtDebugInfo::AssignRef(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
StmtDebugInfo::InvalidAssign(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `StmtDebugInfo`, expected 0..2, actual {0}",
n));
}
}
}
}
};TyDecodable, const _: () =
{
impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
StmtDebugInfo<'tcx> {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
StmtDebugInfo::AssignRef(ref __binding_0, ref __binding_1)
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
StmtDebugInfo::InvalidAssign(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for StmtDebugInfo<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
StmtDebugInfo::AssignRef(__binding_0, __binding_1) => {
StmtDebugInfo::AssignRef(::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?)
}
StmtDebugInfo::InvalidAssign(__binding_0) => {
StmtDebugInfo::InvalidAssign(::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
StmtDebugInfo::AssignRef(__binding_0, __binding_1) => {
StmtDebugInfo::AssignRef(::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder))
}
StmtDebugInfo::InvalidAssign(__binding_0) => {
StmtDebugInfo::InvalidAssign(::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder))
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for StmtDebugInfo<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
StmtDebugInfo::AssignRef(ref __binding_0, ref __binding_1)
=> {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
StmtDebugInfo::InvalidAssign(ref __binding_0) => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
1148pub enum StmtDebugInfo<'tcx> {
1149 AssignRef(Local, Place<'tcx>),
1150 InvalidAssign(Local),
1151}