1use std::fmt::Debug;
4use std::ops;
5
6use rustc_data_structures::outline;
7use rustc_span::bug;
8use thin_vec::ThinVec;
9use tracing::instrument;
10
11use super::interpret::GlobalAlloc;
12use super::*;
13use crate::ty::consts::ConstExt;
14use crate::ty::{CoroutineArgsExt, Unnormalized};
15
16#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for Statement<'tcx> {
#[inline]
fn clone(&self) -> Self {
Self {
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)]
21#[non_exhaustive]
22pub struct Statement<'tcx> {
23 pub source_info: SourceInfo,
24 pub kind: StatementKind<'tcx>,
25 pub debuginfos: StmtDebugInfos<'tcx>,
27}
28
29impl<'tcx> Statement<'tcx> {
30 pub fn make_nop(&mut self, drop_debuginfo: bool) {
33 if self.kind == StatementKind::Nop {
34 return;
35 }
36 let replaced_stmt = std::mem::replace(&mut self.kind, StatementKind::Nop);
37 if !drop_debuginfo {
38 let Some(debuginfo) = replaced_stmt.as_debuginfo() else {
39 ::rustc_span::macros::bug_impl(None,
format_args!("debuginfo is not yet supported."), Location::caller())bug!("debuginfo is not yet supported.")
40 };
41 self.debuginfos.push(debuginfo);
42 }
43 }
44
45 pub fn new(source_info: SourceInfo, kind: StatementKind<'tcx>) -> Self {
46 Statement { source_info, kind, debuginfos: StmtDebugInfos::default() }
47 }
48}
49
50impl<'tcx> StatementKind<'tcx> {
51 pub const fn name(&self) -> &'static str {
54 match self {
55 StatementKind::Assign(..) => "Assign",
56 StatementKind::FakeRead(..) => "FakeRead",
57 StatementKind::SetDiscriminant { .. } => "SetDiscriminant",
58 StatementKind::StorageLive(..) => "StorageLive",
59 StatementKind::StorageDead(..) => "StorageDead",
60 StatementKind::PlaceMention(..) => "PlaceMention",
61 StatementKind::AscribeUserType(..) => "AscribeUserType",
62 StatementKind::Coverage(..) => "Coverage",
63 StatementKind::Intrinsic(..) => "Intrinsic",
64 StatementKind::ConstEvalCounter => "ConstEvalCounter",
65 StatementKind::Nop => "Nop",
66 StatementKind::BackwardIncompatibleDropHint { .. } => "BackwardIncompatibleDropHint",
67 }
68 }
69 pub fn as_assign_mut(&mut self) -> Option<&mut (Place<'tcx>, Rvalue<'tcx>)> {
70 match self {
71 StatementKind::Assign(x) => Some(x),
72 _ => None,
73 }
74 }
75
76 pub fn as_assign(&self) -> Option<&(Place<'tcx>, Rvalue<'tcx>)> {
77 match self {
78 StatementKind::Assign(x) => Some(x),
79 _ => None,
80 }
81 }
82
83 pub fn as_debuginfo(&self) -> Option<StmtDebugInfo<'tcx>> {
84 match self {
85 StatementKind::Assign((place, Rvalue::Ref(_, _, ref_place)))
86 if let Some(local) = place.as_local() =>
87 {
88 Some(StmtDebugInfo::AssignRef(local, *ref_place))
89 }
90 _ => None,
91 }
92 }
93}
94
95#[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) -> Self {
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)]
99pub struct PlaceTy<'tcx> {
100 pub ty: Ty<'tcx>,
101 pub variant_index: Option<VariantIdx>,
103}
104
105#[cfg(target_pointer_width = "64")]
107const _: [(); 16] = [(); ::std::mem::size_of::<PlaceTy<'_>>()];rustc_data_structures::static_assert_size!(PlaceTy<'_>, 16);
108
109impl<'tcx> PlaceTy<'tcx> {
110 #[inline]
111 pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {
112 PlaceTy { ty, variant_index: None }
113 }
114
115 {}
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/d080e7dff1b0fc54541545252818f8cccf995d05/compiler/rustc_middle/src/mir/statement.rs"),
::tracing_core::__macro_support::Option::Some(122u32),
::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 {
::rustc_span::macros::bug_impl(None,
format_args!("variant {0:?} of coroutine out of range: {1:?}",
variant_index, self_ty), Location::caller());
};
Unnormalized::new_wip(variant.nth(f.index()).unwrap_or_else(||
{
::rustc_span::macros::bug_impl(None,
format_args!("field {0:?} out of range of variant: {1:?} {2:?}",
f, self_ty, variant_idx), Location::caller())
}))
}
_ =>
::rustc_span::macros::bug_impl(None,
format_args!("can\'t downcast non-adt non-coroutine type: {0:?}",
self_ty), Location::caller()),
}
} 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(||
::rustc_span::macros::bug_impl(None,
format_args!("field {0:?} out of range: {1:?}", f, self_ty),
Location::caller()))),
ty::CoroutineClosure(_, args) =>
Unnormalized::dummy(args.as_coroutine_closure().upvar_tys().get(f.index()).copied().unwrap_or_else(||
::rustc_span::macros::bug_impl(None,
format_args!("field {0:?} out of range: {1:?}", f, self_ty),
Location::caller()))),
ty::Coroutine(_, args) =>
Unnormalized::dummy(args.as_coroutine().upvar_tys().get(f.index()).copied().unwrap_or_else(||
{
::rustc_span::macros::bug_impl(None,
format_args!("field {0:?} out of range of prefixes for {1}",
f, self_ty), Location::caller())
})),
ty::Tuple(tys) =>
Unnormalized::dummy(tys.get(f.index()).copied().unwrap_or_else(||
::rustc_span::macros::bug_impl(None,
format_args!("field {0:?} out of range: {1:?}", f, self_ty),
Location::caller()))),
_ =>
::rustc_span::macros::bug_impl(None,
format_args!("can\'t project out of {0:?}", self_ty),
Location::caller()),
}
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/d080e7dff1b0fc54541545252818f8cccf995d05/compiler/rustc_middle/src/mir/statement.rs:122",
"rustc_middle::mir::statement", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/d080e7dff1b0fc54541545252818f8cccf995d05/compiler/rustc_middle/src/mir/statement.rs"),
::tracing_core::__macro_support::Option::Some(122u32),
::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)]
123 pub fn field_ty(
124 tcx: TyCtxt<'tcx>,
125 self_ty: Ty<'tcx>,
126 variant_idx: Option<VariantIdx>,
127 f: FieldIdx,
128 ) -> Unnormalized<'tcx, Ty<'tcx>> {
129 if let Some(variant_index) = variant_idx {
130 match *self_ty.kind() {
131 ty::Adt(adt_def, args) if adt_def.is_enum() => {
132 adt_def.variant(variant_index).fields[f].ty(tcx, args)
133 }
134 ty::Coroutine(def_id, args) => {
135 let mut variants = args.as_coroutine().state_tys(def_id, tcx);
136 let Some(mut variant) = variants.nth(variant_index.into()) else {
137 bug!("variant {variant_index:?} of coroutine out of range: {self_ty:?}");
138 };
139
140 Unnormalized::new_wip(variant.nth(f.index()).unwrap_or_else(|| {
141 bug!("field {f:?} out of range of variant: {self_ty:?} {variant_idx:?}")
142 }))
143 }
144 _ => bug!("can't downcast non-adt non-coroutine type: {self_ty:?}"),
145 }
146 } else {
147 match self_ty.kind() {
148 ty::Adt(adt_def, args) if !adt_def.is_enum() => {
149 adt_def.non_enum_variant().fields[f].ty(tcx, args)
150 }
151 ty::Closure(_, args) => Unnormalized::dummy(
152 args.as_closure()
153 .upvar_tys()
154 .get(f.index())
155 .copied()
156 .unwrap_or_else(|| bug!("field {f:?} out of range: {self_ty:?}")),
157 ),
158 ty::CoroutineClosure(_, args) => Unnormalized::dummy(
159 args.as_coroutine_closure()
160 .upvar_tys()
161 .get(f.index())
162 .copied()
163 .unwrap_or_else(|| bug!("field {f:?} out of range: {self_ty:?}")),
164 ),
165 ty::Coroutine(_, args) => Unnormalized::dummy(
167 args.as_coroutine().upvar_tys().get(f.index()).copied().unwrap_or_else(|| {
168 bug!("field {f:?} out of range of prefixes for {self_ty}")
169 }),
170 ),
171 ty::Tuple(tys) => Unnormalized::dummy(
172 tys.get(f.index())
173 .copied()
174 .unwrap_or_else(|| bug!("field {f:?} out of range: {self_ty:?}")),
175 ),
176 _ => bug!("can't project out of {self_ty:?}"),
177 }
178 }
179 }
180
181 pub fn multi_projection_ty(
182 self,
183 tcx: TyCtxt<'tcx>,
184 elems: &[PlaceElem<'tcx>],
185 ) -> PlaceTy<'tcx> {
186 elems.iter().fold(self, |place_ty, &elem| place_ty.projection_ty(tcx, elem))
187 }
188
189 pub fn projection_ty<V: Debug>(
193 self,
194 tcx: TyCtxt<'tcx>,
195 elem: ProjectionElem<V, Ty<'tcx>>,
196 ) -> PlaceTy<'tcx> {
197 self.projection_ty_core(tcx, &elem, |_, _, _, ty| ty, |ty| ty)
198 }
199
200 {}
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/d080e7dff1b0fc54541545252818f8cccf995d05/compiler/rustc_middle/src/mir/statement.rs"),
::tracing_core::__macro_support::Option::Some(205u32),
::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,
} {
::rustc_span::macros::bug_impl(None,
format_args!("cannot use non field projection on downcasted place"),
Location::caller())
}
match *elem {
ProjectionElem::Deref => {
let ty =
self.ty.builtin_deref(true).unwrap_or_else(||
{
::rustc_span::macros::bug_impl(None,
format_args!("deref projection of non-dereferenceable ty {0:?}",
self), Location::caller())
});
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)
}
_ =>
::rustc_span::macros::bug_impl(None,
format_args!("cannot subslice non-array type: `{0:?}`",
self), Location::caller()),
})
}
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/d080e7dff1b0fc54541545252818f8cccf995d05/compiler/rustc_middle/src/mir/statement.rs:205",
"rustc_middle::mir::statement", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/d080e7dff1b0fc54541545252818f8cccf995d05/compiler/rustc_middle/src/mir/statement.rs"),
::tracing_core::__macro_support::Option::Some(205u32),
::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)]
206 pub fn projection_ty_core<V, T>(
207 self,
208 tcx: TyCtxt<'tcx>,
209 elem: &ProjectionElem<V, T>,
210 mut handle_field: impl FnMut(Ty<'tcx>, Option<VariantIdx>, FieldIdx, T) -> Ty<'tcx>,
211 mut handle_opaque_cast_and_subtype: impl FnMut(T) -> Ty<'tcx>,
212 ) -> PlaceTy<'tcx>
213 where
214 V: Debug,
215 T: Debug + Copy,
216 {
217 if self.variant_index.is_some() && !matches!(elem, ProjectionElem::Field(..)) {
218 bug!("cannot use non field projection on downcasted place")
219 }
220 match *elem {
221 ProjectionElem::Deref => {
222 let ty = self.ty.builtin_deref(true).unwrap_or_else(|| {
223 bug!("deref projection of non-dereferenceable ty {:?}", self)
224 });
225 PlaceTy::from_ty(ty)
226 }
227 ProjectionElem::PhantomDeref => PlaceTy::from_ty(self.ty),
228 ProjectionElem::Index(_) | ProjectionElem::ConstantIndex { .. } => {
229 PlaceTy::from_ty(self.ty.builtin_index().unwrap())
230 }
231 ProjectionElem::Subslice { from, to, from_end } => {
232 PlaceTy::from_ty(match self.ty.kind() {
233 ty::Slice(..) => self.ty,
234 ty::Array(inner, _) if !from_end => Ty::new_array(tcx, *inner, to - from),
235 ty::Array(inner, size) if from_end => {
236 let size = size
237 .try_to_target_usize(tcx)
238 .expect("expected subslice projection on fixed-size array");
239 let len = size - from - to;
240 Ty::new_array(tcx, *inner, len)
241 }
242 _ => bug!("cannot subslice non-array type: `{:?}`", self),
243 })
244 }
245 ProjectionElem::Downcast(_name, index) => {
246 PlaceTy { ty: self.ty, variant_index: Some(index) }
247 }
248 ProjectionElem::Field(f, fty) => {
249 PlaceTy::from_ty(handle_field(self.ty, self.variant_index, f, fty))
250 }
251 ProjectionElem::OpaqueCast(ty) => PlaceTy::from_ty(handle_opaque_cast_and_subtype(ty)),
252
253 ProjectionElem::UnwrapUnsafeBinder(ty) => {
255 PlaceTy::from_ty(handle_opaque_cast_and_subtype(ty))
256 }
257 }
258 }
259}
260
261impl<V, T> ProjectionElem<V, T> {
262 pub fn is_indirect(&self) -> bool {
265 match self {
266 Self::Deref | Self::PhantomDeref => true,
267
268 Self::Field(_, _)
269 | Self::Index(_)
270 | Self::OpaqueCast(_)
271 | Self::ConstantIndex { .. }
272 | Self::Subslice { .. }
273 | Self::Downcast(_, _)
274 | Self::UnwrapUnsafeBinder(..) => false,
275 }
276 }
277
278 pub fn is_stable_offset(&self) -> bool {
281 match self {
282 Self::Deref | Self::Index(_) => false,
283 Self::Field(_, _)
284 | Self::OpaqueCast(_)
285 | Self::ConstantIndex { .. }
286 | Self::Subslice { .. }
287 | Self::Downcast(_, _)
288 | Self::UnwrapUnsafeBinder(..)
289 | Self::PhantomDeref => true,
290 }
291 }
292
293 pub fn is_downcast_to(&self, v: VariantIdx) -> bool {
295 #[allow(non_exhaustive_omitted_patterns)] match *self {
Self::Downcast(_, x) if x == v => true,
_ => false,
}matches!(*self, Self::Downcast(_, x) if x == v)
296 }
297
298 pub fn is_field_to(&self, f: FieldIdx) -> bool {
300 #[allow(non_exhaustive_omitted_patterns)] match *self {
Self::Field(x, _) if x == f => true,
_ => false,
}matches!(*self, Self::Field(x, _) if x == f)
301 }
302
303 pub fn can_use_in_debuginfo(&self) -> bool {
305 match self {
306 Self::ConstantIndex { from_end: false, .. }
307 | Self::Deref
308 | Self::Downcast(_, _)
309 | Self::Field(_, _) => true,
310 Self::ConstantIndex { from_end: true, .. }
311 | Self::Index(_)
312 | Self::OpaqueCast(_)
313 | Self::Subslice { .. }
314 | Self::PhantomDeref => false,
315
316 Self::UnwrapUnsafeBinder(..) => false,
318 }
319 }
320
321 pub fn kind(self) -> ProjectionKind {
323 self.try_map(|_| Some(()), |_| ()).unwrap()
324 }
325
326 pub fn try_map<V2, T2>(
328 self,
329 v: impl FnOnce(V) -> Option<V2>,
330 t: impl FnOnce(T) -> T2,
331 ) -> Option<ProjectionElem<V2, T2>> {
332 Some(match self {
333 ProjectionElem::Deref => ProjectionElem::Deref,
334 ProjectionElem::PhantomDeref => ::rustc_span::macros::bug_impl(None,
format_args!("PhantomDeref shouldn\'t hopefully come here"),
Location::caller())bug!("PhantomDeref shouldn't hopefully come here"),
335 ProjectionElem::Downcast(name, read_variant) => {
336 ProjectionElem::Downcast(name, read_variant)
337 }
338 ProjectionElem::Field(f, ty) => ProjectionElem::Field(f, t(ty)),
339 ProjectionElem::ConstantIndex { offset, min_length, from_end } => {
340 ProjectionElem::ConstantIndex { offset, min_length, from_end }
341 }
342 ProjectionElem::Subslice { from, to, from_end } => {
343 ProjectionElem::Subslice { from, to, from_end }
344 }
345 ProjectionElem::OpaqueCast(ty) => ProjectionElem::OpaqueCast(t(ty)),
346 ProjectionElem::UnwrapUnsafeBinder(ty) => ProjectionElem::UnwrapUnsafeBinder(t(ty)),
347 ProjectionElem::Index(val) => ProjectionElem::Index(v(val)?),
348 })
349 }
350}
351
352pub type ProjectionKind = ProjectionElem<(), ()>;
355
356#[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) -> Self {
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: &Self) -> 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)]
357pub struct PlaceRef<'tcx> {
358 pub local: Local,
359 pub projection: &'tcx [PlaceElem<'tcx>],
360}
361
362impl<'tcx> !PartialOrd for PlaceRef<'tcx> {}
367
368impl<'tcx> Place<'tcx> {
369 pub fn return_place() -> Place<'tcx> {
371 Place { local: RETURN_PLACE, projection: List::empty() }
372 }
373
374 pub fn is_indirect(&self) -> bool {
379 self.projection.iter().any(|elem| elem.is_indirect())
380 }
381
382 pub fn is_stable_offset(&self) -> bool {
385 self.projection.iter().all(|elem| elem.is_stable_offset())
386 }
387
388 pub fn is_indirect_first_projection(&self) -> bool {
394 self.as_ref().is_indirect_first_projection()
395 }
396
397 #[inline(always)]
400 pub fn local_or_deref_local(&self) -> Option<Local> {
401 self.as_ref().local_or_deref_local()
402 }
403
404 #[inline(always)]
407 pub fn as_local(&self) -> Option<Local> {
408 self.as_ref().as_local()
409 }
410
411 #[inline]
412 pub fn as_ref(&self) -> PlaceRef<'tcx> {
413 PlaceRef { local: self.local, projection: self.projection }
414 }
415
416 #[inline]
424 pub fn iter_projections(
425 self,
426 ) -> impl Iterator<Item = (PlaceRef<'tcx>, PlaceElem<'tcx>)> + DoubleEndedIterator {
427 self.as_ref().iter_projections()
428 }
429
430 pub fn project_deeper(self, more_projections: &[PlaceElem<'tcx>], tcx: TyCtxt<'tcx>) -> Self {
433 if more_projections.is_empty() {
434 return self;
435 }
436
437 self.as_ref().project_deeper(more_projections, tcx)
438 }
439
440 pub fn project_to_field(
444 self,
445 idx: FieldIdx,
446 local_decls: &(impl HasLocalDecls<'tcx> + ?Sized),
447 tcx: TyCtxt<'tcx>,
448 ) -> Self {
449 let ty = self.ty(local_decls, tcx).ty;
450 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}") };
451 let field = &adt.non_enum_variant().fields[idx];
452 let field_ty = field.ty(tcx, args).skip_norm_wip();
453 self.project_deeper(&[ProjectionElem::Field(idx, field_ty)], tcx)
454 }
455
456 pub fn ty_from<D>(
457 local: Local,
458 projection: &[PlaceElem<'tcx>],
459 local_decls: &D,
460 tcx: TyCtxt<'tcx>,
461 ) -> PlaceTy<'tcx>
462 where
463 D: ?Sized + HasLocalDecls<'tcx>,
464 {
465 PlaceTy::from_ty(local_decls.local_decls()[local].ty).multi_projection_ty(tcx, projection)
468 }
469
470 pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
471 where
472 D: HasLocalDecls<'tcx>,
473 {
474 Place::ty_from(self.local, self.projection, local_decls, tcx)
475 }
476}
477
478impl From<Local> for Place<'_> {
479 #[inline]
480 fn from(local: Local) -> Self {
481 Place { local, projection: List::empty() }
482 }
483}
484
485impl<'tcx> PlaceRef<'tcx> {
486 pub fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool {
487 self.local == other.local
488 && self.projection.len() <= other.projection.len()
489 && self.projection == &other.projection[..self.projection.len()]
490 }
491
492 pub fn local_or_deref_local(&self) -> Option<Local> {
495 match *self {
496 PlaceRef { local, projection: [] }
497 | PlaceRef {
498 local,
499 projection: [ProjectionElem::Deref | ProjectionElem::PhantomDeref],
500 } => Some(local),
501 _ => None,
502 }
503 }
504
505 pub fn is_indirect(&self) -> bool {
510 self.projection.iter().any(|elem| elem.is_indirect())
511 }
512
513 pub fn is_indirect_first_projection(&self) -> bool {
519 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!(
521 self.projection.is_empty() || !self.projection[1..].contains(&PlaceElem::Deref)
522 );
523 self.projection.first() == Some(&PlaceElem::Deref)
524 }
525
526 #[inline]
529 pub fn as_local(&self) -> Option<Local> {
530 match *self {
531 PlaceRef { local, projection: [] } => Some(local),
532 _ => None,
533 }
534 }
535
536 #[inline]
537 pub fn to_place(&self, tcx: TyCtxt<'tcx>) -> Place<'tcx> {
538 Place { local: self.local, projection: tcx.mk_place_elems(self.projection) }
539 }
540
541 #[inline]
542 pub fn last_projection(&self) -> Option<(PlaceRef<'tcx>, PlaceElem<'tcx>)> {
543 if let &[ref proj_base @ .., elem] = self.projection {
544 Some((PlaceRef { local: self.local, projection: proj_base }, elem))
545 } else {
546 None
547 }
548 }
549
550 #[inline]
558 pub fn iter_projections(
559 self,
560 ) -> impl Iterator<Item = (PlaceRef<'tcx>, PlaceElem<'tcx>)> + DoubleEndedIterator {
561 self.projection.iter().enumerate().map(move |(i, proj)| {
562 let base = PlaceRef { local: self.local, projection: &self.projection[..i] };
563 (base, *proj)
564 })
565 }
566
567 pub fn accessed_locals(self) -> impl Iterator<Item = Local> {
569 std::iter::once(self.local).chain(self.projection.iter().filter_map(|proj| match proj {
570 ProjectionElem::Index(local) => Some(*local),
571 ProjectionElem::Deref
572 | ProjectionElem::PhantomDeref
573 | ProjectionElem::Field(_, _)
574 | ProjectionElem::ConstantIndex { .. }
575 | ProjectionElem::Subslice { .. }
576 | ProjectionElem::Downcast(_, _)
577 | ProjectionElem::OpaqueCast(_)
578 | ProjectionElem::UnwrapUnsafeBinder(_) => None,
579 }))
580 }
581
582 pub fn project_deeper(
585 self,
586 more_projections: &[PlaceElem<'tcx>],
587 tcx: TyCtxt<'tcx>,
588 ) -> Place<'tcx> {
589 let mut v: Vec<PlaceElem<'tcx>>;
590
591 let new_projections = if self.projection.is_empty() {
592 more_projections
593 } else {
594 v = Vec::with_capacity(self.projection.len() + more_projections.len());
595 v.extend(self.projection);
596 v.extend(more_projections);
597 &v
598 };
599
600 Place { local: self.local, projection: tcx.mk_place_elems(new_projections) }
601 }
602
603 pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
604 where
605 D: ?Sized + HasLocalDecls<'tcx>,
606 {
607 Place::ty_from(self.local, self.projection, local_decls, tcx)
608 }
609}
610
611impl From<Local> for PlaceRef<'_> {
612 #[inline]
613 fn from(local: Local) -> Self {
614 PlaceRef { local, projection: &[] }
615 }
616}
617
618impl<'tcx> Operand<'tcx> {
622 pub fn function_handle(
626 tcx: TyCtxt<'tcx>,
627 def_id: DefId,
628 args: &[GenericArg<'tcx>],
629 span: Span,
630 ) -> Self {
631 Operand::zero_sized_constant(
632 tcx.type_of(def_id).instantiate(tcx, args).skip_norm_wip(),
633 span,
634 )
635 }
636
637 pub fn unevaluated_constant(
640 tcx: TyCtxt<'tcx>,
641 def_id: DefId,
642 args: &[GenericArg<'tcx>],
643 span: Span,
644 ) -> Self {
645 let const_ = Const::from_unevaluated(tcx, def_id).instantiate(tcx, args).skip_norm_wip();
646 Operand::Constant(Box::new(ConstOperand { span, user_ty: None, const_ }))
647 }
648
649 pub fn zero_sized_constant(ty: Ty<'tcx>, span: Span) -> Self {
651 let const_ = Const::Val(ConstValue::ZeroSized, ty);
652 Operand::Constant(Box::new(ConstOperand { span, user_ty: None, const_ }))
653 }
654
655 pub fn is_move(&self) -> bool {
656 #[allow(non_exhaustive_omitted_patterns)] match self {
Operand::Move(..) => true,
_ => false,
}matches!(self, Operand::Move(..))
657 }
658
659 pub fn const_from_scalar(
662 tcx: TyCtxt<'tcx>,
663 ty: Ty<'tcx>,
664 val: Scalar,
665 span: Span,
666 ) -> Operand<'tcx> {
667 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!({
668 let typing_env = ty::TypingEnv::fully_monomorphized();
669 let type_size = tcx
670 .layout_of(typing_env.as_query_input(ty))
671 .unwrap_or_else(|e| panic!("could not compute layout for {ty:?}: {e:?}"))
672 .size;
673 let scalar_size = match val {
674 Scalar::Int(int) => int.size(),
675 _ => panic!("Invalid scalar type {val:?}"),
676 };
677 scalar_size == type_size
678 });
679 Operand::Constant(Box::new(ConstOperand {
680 span,
681 user_ty: None,
682 const_: Const::Val(ConstValue::Scalar(val), ty),
683 }))
684 }
685
686 pub fn to_copy(&self) -> Self {
687 match *self {
688 Operand::Copy(_) | Operand::Constant(_) | Operand::RuntimeChecks(_) => self.clone(),
689 Operand::Move(place) => Operand::Copy(place),
690 }
691 }
692
693 pub fn place(&self) -> Option<Place<'tcx>> {
696 match self {
697 Operand::Copy(place) | Operand::Move(place) => Some(*place),
698 Operand::Constant(_) | Operand::RuntimeChecks(_) => None,
699 }
700 }
701
702 pub fn constant(&self) -> Option<&ConstOperand<'tcx>> {
705 match self {
706 Operand::Constant(x) => Some(&**x),
707 Operand::Copy(_) | Operand::Move(_) | Operand::RuntimeChecks(_) => None,
708 }
709 }
710
711 pub fn const_fn_def(&self) -> Option<(DefId, GenericArgsRef<'tcx>)> {
716 let const_ty = self.constant()?.const_.ty();
717 if let ty::FnDef(def_id, args) = *const_ty.kind() {
718 Some((def_id, args.no_bound_vars().unwrap()))
719 } else {
720 None
721 }
722 }
723
724 pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
725 where
726 D: ?Sized + HasLocalDecls<'tcx>,
727 {
728 match self {
729 &Operand::Copy(ref l) | &Operand::Move(ref l) => l.ty(local_decls, tcx).ty,
730 Operand::Constant(c) => c.const_.ty(),
731 Operand::RuntimeChecks(_) => tcx.types.bool,
732 }
733 }
734
735 pub fn span<D>(&self, local_decls: &D) -> Span
736 where
737 D: ?Sized + HasLocalDecls<'tcx>,
738 {
739 match self {
740 &Operand::Copy(ref l) | &Operand::Move(ref l) => {
741 local_decls.local_decls()[l.local].source_info.span
742 }
743 Operand::Constant(c) => c.span,
744 Operand::RuntimeChecks(_) => DUMMY_SP,
746 }
747 }
748}
749
750impl<'tcx> ConstOperand<'tcx> {
751 pub fn check_static_ptr(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
752 match self.const_.try_to_scalar() {
753 Some(Scalar::Ptr(ptr, _size)) => match tcx.global_alloc(ptr.provenance.alloc_id()) {
754 GlobalAlloc::Static(def_id) => {
755 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));
756 Some(def_id)
757 }
758 _ => None,
759 },
760 _ => None,
761 }
762 }
763
764 #[inline]
765 pub fn ty(&self) -> Ty<'tcx> {
766 self.const_.ty()
767 }
768}
769
770impl<'tcx> Rvalue<'tcx> {
774 #[inline]
776 pub fn is_safe_to_remove(&self) -> bool {
777 match self {
778 Rvalue::Cast(CastKind::PointerExposeProvenance, _, _) => false,
782
783 Rvalue::Use(_, _)
784 | Rvalue::CopyForDeref(_)
785 | Rvalue::Repeat(_, _)
786 | Rvalue::Ref(_, _, _)
787 | Rvalue::Reborrow(_, _, _)
788 | Rvalue::ThreadLocalRef(_)
789 | Rvalue::RawPtr(_, _)
790 | Rvalue::Cast(
791 CastKind::IntToInt
792 | CastKind::FloatToInt
793 | CastKind::FloatToFloat
794 | CastKind::IntToFloat
795 | CastKind::FnPtrToPtr
796 | CastKind::PtrToPtr
797 | CastKind::PointerCoercion(_, _)
798 | CastKind::PointerWithExposedProvenance
799 | CastKind::Transmute
800 | CastKind::BoxDerefTransmute
801 | CastKind::Subtype,
802 _,
803 _,
804 )
805 | Rvalue::BinaryOp(_, _)
806 | Rvalue::UnaryOp(_, _)
807 | Rvalue::Discriminant(_)
808 | Rvalue::Aggregate(_, _)
809 | Rvalue::WrapUnsafeBinder(_, _) => true,
810 }
811 }
812
813 pub fn is_generic_reborrow(&self) -> bool {
816 #[allow(non_exhaustive_omitted_patterns)] match self {
Self::Reborrow(..) => true,
_ => false,
}matches!(self, Self::Reborrow(..))
817 }
818
819 pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
820 where
821 D: ?Sized + HasLocalDecls<'tcx>,
822 {
823 match *self {
824 Rvalue::Use(ref operand, _) => operand.ty(local_decls, tcx),
825 Rvalue::Repeat(ref operand, count) => {
826 Ty::new_array_with_const_len(tcx, operand.ty(local_decls, tcx), count)
827 }
828 Rvalue::ThreadLocalRef(did) => tcx.thread_local_ptr_ty(did),
829 Rvalue::Ref(reg, bk, ref place) => {
830 let place_ty = place.ty(local_decls, tcx).ty;
831 Ty::new_ref(tcx, reg, place_ty, bk.to_mutbl_lossy())
832 }
833 Rvalue::Reborrow(target, _, _) => target,
834 Rvalue::RawPtr(kind, ref place) => {
835 let place_ty = place.ty(local_decls, tcx).ty;
836 Ty::new_ptr(tcx, place_ty, kind.to_mutbl_lossy())
837 }
838 Rvalue::Cast(.., ty) => ty,
839 Rvalue::BinaryOp(op, (ref lhs, ref rhs)) => {
840 let lhs_ty = lhs.ty(local_decls, tcx);
841 let rhs_ty = rhs.ty(local_decls, tcx);
842 op.ty(tcx, lhs_ty, rhs_ty)
843 }
844 Rvalue::UnaryOp(op, ref operand) => {
845 let arg_ty = operand.ty(local_decls, tcx);
846 op.ty(tcx, arg_ty)
847 }
848 Rvalue::Discriminant(ref place) => place.ty(local_decls, tcx).ty.discriminant_ty(tcx),
849 Rvalue::Aggregate(ref ak, ref ops) => match **ak {
850 AggregateKind::Array(ty) => Ty::new_array(tcx, ty, ops.len() as u64),
851 AggregateKind::Tuple => {
852 Ty::new_tup_from_iter(tcx, ops.iter().map(|op| op.ty(local_decls, tcx)))
853 }
854 AggregateKind::Adt(did, _, args, _, _) => {
855 tcx.type_of(did).instantiate(tcx, args).skip_norm_wip()
856 }
857 AggregateKind::Closure(did, args) => Ty::new_closure(tcx, did, args),
858 AggregateKind::Coroutine(did, args) => Ty::new_coroutine(tcx, did, args),
859 AggregateKind::CoroutineClosure(did, args) => {
860 Ty::new_coroutine_closure(tcx, did, args)
861 }
862 AggregateKind::RawPtr(ty, mutability) => Ty::new_ptr(tcx, ty, mutability),
863 },
864 Rvalue::CopyForDeref(ref place) => place.ty(local_decls, tcx).ty,
865 Rvalue::WrapUnsafeBinder(_, ty) => ty,
866 }
867 }
868}
869
870impl BorrowKind {
871 pub fn mutability(&self) -> Mutability {
872 match *self {
873 BorrowKind::Shared | BorrowKind::Fake(_) => Mutability::Not,
874 BorrowKind::Mut { .. } => Mutability::Mut,
875 }
876 }
877
878 pub fn is_two_phase_borrow(&self) -> bool {
881 match *self {
882 BorrowKind::Shared
883 | BorrowKind::Fake(_)
884 | BorrowKind::Mut { kind: MutBorrowKind::Default | MutBorrowKind::ClosureCapture } => {
885 false
886 }
887 BorrowKind::Mut { kind: MutBorrowKind::TwoPhaseBorrow } => true,
888 }
889 }
890
891 pub fn to_mutbl_lossy(self) -> hir::Mutability {
892 match self {
893 BorrowKind::Mut { .. } => hir::Mutability::Mut,
894 BorrowKind::Shared => hir::Mutability::Not,
895
896 BorrowKind::Fake(_) => hir::Mutability::Not,
899 }
900 }
901}
902
903impl<'tcx> UnOp {
904 pub fn ty(&self, tcx: TyCtxt<'tcx>, arg_ty: Ty<'tcx>) -> Ty<'tcx> {
905 match self {
906 UnOp::Not | UnOp::Neg => arg_ty,
907 UnOp::PtrMetadata => arg_ty.pointee_metadata_ty_or_projection(tcx),
908 }
909 }
910}
911
912impl<'tcx> BinOp {
913 pub fn ty(&self, tcx: TyCtxt<'tcx>, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>) -> Ty<'tcx> {
914 match self {
916 &BinOp::Add
917 | &BinOp::AddUnchecked
918 | &BinOp::Sub
919 | &BinOp::SubUnchecked
920 | &BinOp::Mul
921 | &BinOp::MulUnchecked
922 | &BinOp::Div
923 | &BinOp::Rem
924 | &BinOp::BitXor
925 | &BinOp::BitAnd
926 | &BinOp::BitOr => {
927 {
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);
929 lhs_ty
930 }
931 &BinOp::AddWithOverflow | &BinOp::SubWithOverflow | &BinOp::MulWithOverflow => {
932 {
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);
934 Ty::new_tup(tcx, &[lhs_ty, tcx.types.bool])
935 }
936 &BinOp::Shl
937 | &BinOp::ShlUnchecked
938 | &BinOp::Shr
939 | &BinOp::ShrUnchecked
940 | &BinOp::Offset => {
941 lhs_ty }
943 &BinOp::Eq | &BinOp::Lt | &BinOp::Le | &BinOp::Ne | &BinOp::Ge | &BinOp::Gt => {
944 tcx.types.bool
945 }
946 &BinOp::Cmp => {
947 {
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);
949 tcx.ty_ordering_enum(DUMMY_SP)
950 }
951 }
952 }
953 pub(crate) fn to_hir_binop(self) -> hir::BinOpKind {
954 match self {
955 BinOp::Add | BinOp::AddWithOverflow => hir::BinOpKind::Add,
958 BinOp::Sub | BinOp::SubWithOverflow => hir::BinOpKind::Sub,
959 BinOp::Mul | BinOp::MulWithOverflow => hir::BinOpKind::Mul,
960 BinOp::Div => hir::BinOpKind::Div,
961 BinOp::Rem => hir::BinOpKind::Rem,
962 BinOp::BitXor => hir::BinOpKind::BitXor,
963 BinOp::BitAnd => hir::BinOpKind::BitAnd,
964 BinOp::BitOr => hir::BinOpKind::BitOr,
965 BinOp::Shl => hir::BinOpKind::Shl,
966 BinOp::Shr => hir::BinOpKind::Shr,
967 BinOp::Eq => hir::BinOpKind::Eq,
968 BinOp::Ne => hir::BinOpKind::Ne,
969 BinOp::Lt => hir::BinOpKind::Lt,
970 BinOp::Gt => hir::BinOpKind::Gt,
971 BinOp::Le => hir::BinOpKind::Le,
972 BinOp::Ge => hir::BinOpKind::Ge,
973 BinOp::Cmp
975 | BinOp::AddUnchecked
976 | BinOp::SubUnchecked
977 | BinOp::MulUnchecked
978 | BinOp::ShlUnchecked
979 | BinOp::ShrUnchecked
980 | BinOp::Offset => {
981 ::core::panicking::panic("internal error: entered unreachable code")unreachable!()
982 }
983 }
984 }
985
986 pub fn overflowing_to_wrapping(self) -> Option<BinOp> {
988 Some(match self {
989 BinOp::AddWithOverflow => BinOp::Add,
990 BinOp::SubWithOverflow => BinOp::Sub,
991 BinOp::MulWithOverflow => BinOp::Mul,
992 _ => return None,
993 })
994 }
995
996 pub fn is_overflowing(self) -> bool {
998 self.overflowing_to_wrapping().is_some()
999 }
1000
1001 pub fn wrapping_to_overflowing(self) -> Option<BinOp> {
1003 Some(match self {
1004 BinOp::Add => BinOp::AddWithOverflow,
1005 BinOp::Sub => BinOp::SubWithOverflow,
1006 BinOp::Mul => BinOp::MulWithOverflow,
1007 _ => return None,
1008 })
1009 }
1010}
1011
1012impl From<Mutability> for RawPtrKind {
1013 fn from(other: Mutability) -> Self {
1014 match other {
1015 Mutability::Mut => RawPtrKind::Mut,
1016 Mutability::Not => RawPtrKind::Const,
1017 }
1018 }
1019}
1020
1021impl RawPtrKind {
1022 pub fn is_fake(self) -> bool {
1023 match self {
1024 RawPtrKind::Mut | RawPtrKind::Const => false,
1025 RawPtrKind::FakeForPtrMetadata => true,
1026 }
1027 }
1028
1029 pub fn to_mutbl_lossy(self) -> Mutability {
1030 match self {
1031 RawPtrKind::Mut => Mutability::Mut,
1032 RawPtrKind::Const => Mutability::Not,
1033
1034 RawPtrKind::FakeForPtrMetadata => Mutability::Not,
1037 }
1038 }
1039
1040 pub fn ptr_str(self) -> &'static str {
1041 match self {
1042 RawPtrKind::Mut => "mut",
1043 RawPtrKind::Const => "const",
1044 RawPtrKind::FakeForPtrMetadata => "const (fake)",
1045 }
1046 }
1047}
1048
1049#[derive(#[automatically_derived]
impl<'tcx> ::core::default::Default for StmtDebugInfos<'tcx> {
#[inline]
fn default() -> Self { Self(::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) -> Self { Self(::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)]
1057pub struct StmtDebugInfos<'tcx>(Option<ThinVec<StmtDebugInfo<'tcx>>>);
1058
1059impl<'tcx> StmtDebugInfos<'tcx> {
1060 pub fn push(&mut self, debuginfo: StmtDebugInfo<'tcx>) {
1061 self.0.get_or_insert_default().push(debuginfo);
1062 }
1063 #[inline]
1064 pub fn drop_debuginfo(&mut self) {
1065 match &mut self.0 {
1066 None => (),
1067 Some(v) => outline(move || v.clear()),
1068 }
1069 }
1070
1071 #[inline]
1072 pub fn is_empty(&self) -> bool {
1073 match &self.0 {
1074 None => true,
1075 Some(v) => outline(move || v.is_empty()),
1076 }
1077 }
1078 #[inline]
1079 pub fn prepend(&mut self, debuginfos: &mut Self) {
1080 if debuginfos.is_empty() {
1081 return;
1082 };
1083 outline(move || {
1084 debuginfos.append(self);
1085 std::mem::swap(debuginfos, self);
1086 })
1087 }
1088 #[inline]
1089 pub fn append(&mut self, debuginfos: &mut Self) {
1090 if debuginfos.is_empty() {
1091 return;
1092 };
1093 outline(move || self.0.get_or_insert_default().append(debuginfos.0.as_mut().unwrap()));
1094 }
1095 #[inline]
1096 pub fn extend(&mut self, debuginfos: &Self) {
1097 if debuginfos.is_empty() {
1098 return;
1099 };
1100 outline(move || self.0.get_or_insert_default().extend_from_slice(debuginfos.as_slice()))
1101 }
1102
1103 #[inline]
1104 pub fn as_slice(&self) -> &[StmtDebugInfo<'tcx>] {
1105 match &self.0 {
1106 None => &[],
1107 Some(items) => outline(move || items.as_slice()),
1108 }
1109 }
1110
1111 #[inline]
1112 pub fn as_mut_slice(&mut self) -> &mut [StmtDebugInfo<'tcx>] {
1113 match &mut self.0 {
1114 None => &mut [],
1115 Some(items) => outline(move || items.as_mut_slice()),
1116 }
1117 }
1118 #[inline]
1119 pub fn retain_locals(&mut self, locals: &DenseBitSet<Local>) {
1120 match &mut self.0 {
1121 None => (),
1122 Some(items) => outline(move || {
1123 items.retain(|debuginfo| match debuginfo {
1124 StmtDebugInfo::AssignRef(local, _) | StmtDebugInfo::InvalidAssign(local) => {
1125 locals.contains(*local)
1126 }
1127 })
1128 }),
1129 }
1130 }
1131}
1132
1133impl<'tcx> ops::Deref for StmtDebugInfos<'tcx> {
1134 type Target = [StmtDebugInfo<'tcx>];
1135
1136 #[inline]
1137 fn deref(&self) -> &Self::Target {
1138 self.as_slice()
1139 }
1140}
1141
1142impl<'tcx> ops::DerefMut for StmtDebugInfos<'tcx> {
1143 #[inline]
1144 fn deref_mut(&mut self) -> &mut Self::Target {
1145 self.as_mut_slice()
1146 }
1147}
1148
1149#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for StmtDebugInfo<'tcx> {
#[inline]
fn clone(&self) -> Self {
match self {
Self::AssignRef(__self_0, __self_1) =>
Self::AssignRef(::core::clone::Clone::clone(__self_0),
::core::clone::Clone::clone(__self_1)),
Self::InvalidAssign(__self_0) =>
Self::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)]
1150pub enum StmtDebugInfo<'tcx> {
1151 AssignRef(Local, Place<'tcx>),
1152 InvalidAssign(Local),
1153}