Skip to main content

rustc_middle/mir/
statement.rs

1//! Functionality for statements, operands, places, and things that appear in them.
2
3use std::ops;
4
5use rustc_data_structures::outline;
6use tracing::{debug, instrument};
7
8use super::interpret::GlobalAlloc;
9use super::*;
10use crate::ty::{CoroutineArgsExt, Unnormalized};
11
12///////////////////////////////////////////////////////////////////////////
13// Statements
14
15/// A statement in a basic block, including information about its source code.
16#[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) {
                match *self {
                    Statement {
                        source_info: ref __binding_0,
                        kind: ref __binding_1,
                        debuginfos: ref __binding_2 } => {
                        ::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)]
17#[non_exhaustive]
18pub struct Statement<'tcx> {
19    pub source_info: SourceInfo,
20    pub kind: StatementKind<'tcx>,
21    /// Some debuginfos appearing before the primary statement.
22    pub debuginfos: StmtDebugInfos<'tcx>,
23}
24
25impl<'tcx> Statement<'tcx> {
26    /// Changes a statement to a nop. This is both faster than deleting instructions and avoids
27    /// invalidating statement indices in `Location`s.
28    pub fn make_nop(&mut self, drop_debuginfo: bool) {
29        if self.kind == StatementKind::Nop {
30            return;
31        }
32        let replaced_stmt = std::mem::replace(&mut self.kind, StatementKind::Nop);
33        if !drop_debuginfo {
34            let Some(debuginfo) = replaced_stmt.as_debuginfo() else {
35                crate::util::bug::bug_fmt(format_args!("debuginfo is not yet supported."))bug!("debuginfo is not yet supported.")
36            };
37            self.debuginfos.push(debuginfo);
38        }
39    }
40
41    pub fn new(source_info: SourceInfo, kind: StatementKind<'tcx>) -> Self {
42        Statement { source_info, kind, debuginfos: StmtDebugInfos::default() }
43    }
44}
45
46impl<'tcx> StatementKind<'tcx> {
47    /// Returns a simple string representation of a `StatementKind` variant, independent of any
48    /// values it might hold (e.g. `StatementKind::Assign` always returns `"Assign"`).
49    pub const fn name(&self) -> &'static str {
50        match self {
51            StatementKind::Assign(..) => "Assign",
52            StatementKind::FakeRead(..) => "FakeRead",
53            StatementKind::SetDiscriminant { .. } => "SetDiscriminant",
54            StatementKind::StorageLive(..) => "StorageLive",
55            StatementKind::StorageDead(..) => "StorageDead",
56            StatementKind::PlaceMention(..) => "PlaceMention",
57            StatementKind::AscribeUserType(..) => "AscribeUserType",
58            StatementKind::Coverage(..) => "Coverage",
59            StatementKind::Intrinsic(..) => "Intrinsic",
60            StatementKind::ConstEvalCounter => "ConstEvalCounter",
61            StatementKind::Nop => "Nop",
62            StatementKind::BackwardIncompatibleDropHint { .. } => "BackwardIncompatibleDropHint",
63        }
64    }
65    pub fn as_assign_mut(&mut self) -> Option<&mut (Place<'tcx>, Rvalue<'tcx>)> {
66        match self {
67            StatementKind::Assign(x) => Some(x),
68            _ => None,
69        }
70    }
71
72    pub fn as_assign(&self) -> Option<&(Place<'tcx>, Rvalue<'tcx>)> {
73        match self {
74            StatementKind::Assign(x) => Some(x),
75            _ => None,
76        }
77    }
78
79    pub fn as_debuginfo(&self) -> Option<StmtDebugInfo<'tcx>> {
80        match self {
81            StatementKind::Assign((place, Rvalue::Ref(_, _, ref_place)))
82                if let Some(local) = place.as_local() =>
83            {
84                Some(StmtDebugInfo::AssignRef(local, *ref_place))
85            }
86            _ => None,
87        }
88    }
89}
90
91///////////////////////////////////////////////////////////////////////////
92// Places
93
94#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for PlaceTy<'tcx> { }Copy, #[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)]
95pub struct PlaceTy<'tcx> {
96    pub ty: Ty<'tcx>,
97    /// Downcast to a particular variant of an enum or a coroutine, if included.
98    pub variant_index: Option<VariantIdx>,
99}
100
101// At least on 64 bit systems, `PlaceTy` should not be larger than two or three pointers.
102#[cfg(target_pointer_width = "64")]
103const _: [(); 16] = [(); ::std::mem::size_of::<PlaceTy<'_>>()];rustc_data_structures::static_assert_size!(PlaceTy<'_>, 16);
104
105impl<'tcx> PlaceTy<'tcx> {
106    #[inline]
107    pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {
108        PlaceTy { ty, variant_index: None }
109    }
110
111    /// `place_ty.field_ty(tcx, f)` computes the type of a given field.
112    ///
113    /// Most clients of `PlaceTy` can instead just extract the relevant type
114    /// directly from their `PlaceElem`, but some instances of `ProjectionElem<V, T>`
115    /// do not carry a `Ty` for `T`.
116    ///
117    /// Note that the resulting type has not been normalized.
118    x;#[instrument(level = "debug", skip(tcx), ret)]
119    pub fn field_ty(
120        tcx: TyCtxt<'tcx>,
121        self_ty: Ty<'tcx>,
122        variant_idx: Option<VariantIdx>,
123        f: FieldIdx,
124    ) -> Unnormalized<'tcx, Ty<'tcx>> {
125        if let Some(variant_index) = variant_idx {
126            match *self_ty.kind() {
127                ty::Adt(adt_def, args) if adt_def.is_enum() => {
128                    adt_def.variant(variant_index).fields[f].ty(tcx, args)
129                }
130                ty::Coroutine(def_id, args) => {
131                    let mut variants = args.as_coroutine().state_tys(def_id, tcx);
132                    let Some(mut variant) = variants.nth(variant_index.into()) else {
133                        bug!("variant {variant_index:?} of coroutine out of range: {self_ty:?}");
134                    };
135
136                    Unnormalized::new_wip(variant.nth(f.index()).unwrap_or_else(|| {
137                        bug!("field {f:?} out of range of variant: {self_ty:?} {variant_idx:?}")
138                    }))
139                }
140                _ => bug!("can't downcast non-adt non-coroutine type: {self_ty:?}"),
141            }
142        } else {
143            match self_ty.kind() {
144                ty::Adt(adt_def, args) if !adt_def.is_enum() => {
145                    adt_def.non_enum_variant().fields[f].ty(tcx, args)
146                }
147                ty::Closure(_, args) => Unnormalized::dummy(
148                    args.as_closure()
149                        .upvar_tys()
150                        .get(f.index())
151                        .copied()
152                        .unwrap_or_else(|| bug!("field {f:?} out of range: {self_ty:?}")),
153                ),
154                ty::CoroutineClosure(_, args) => Unnormalized::dummy(
155                    args.as_coroutine_closure()
156                        .upvar_tys()
157                        .get(f.index())
158                        .copied()
159                        .unwrap_or_else(|| bug!("field {f:?} out of range: {self_ty:?}")),
160                ),
161                // Only upvars are accessible without a variant index.
162                ty::Coroutine(_, args) => Unnormalized::dummy(
163                    args.as_coroutine().upvar_tys().get(f.index()).copied().unwrap_or_else(|| {
164                        bug!("field {f:?} out of range of prefixes for {self_ty}")
165                    }),
166                ),
167                ty::Tuple(tys) => Unnormalized::dummy(
168                    tys.get(f.index())
169                        .copied()
170                        .unwrap_or_else(|| bug!("field {f:?} out of range: {self_ty:?}")),
171                ),
172                _ => bug!("can't project out of {self_ty:?}"),
173            }
174        }
175    }
176
177    pub fn multi_projection_ty(
178        self,
179        tcx: TyCtxt<'tcx>,
180        elems: &[PlaceElem<'tcx>],
181    ) -> PlaceTy<'tcx> {
182        elems.iter().fold(self, |place_ty, &elem| place_ty.projection_ty(tcx, elem))
183    }
184
185    /// Convenience wrapper around `projection_ty_core` for `PlaceElem`,
186    /// where we can just use the `Ty` that is already stored inline on
187    /// field projection elems.
188    pub fn projection_ty<V: ::std::fmt::Debug>(
189        self,
190        tcx: TyCtxt<'tcx>,
191        elem: ProjectionElem<V, Ty<'tcx>>,
192    ) -> PlaceTy<'tcx> {
193        self.projection_ty_core(tcx, &elem, |ty| ty, |_, _, _, ty| ty, |ty| ty)
194    }
195
196    /// `place_ty.projection_ty_core(tcx, elem, |...| { ... })`
197    /// projects `place_ty` onto `elem`, returning the appropriate
198    /// `Ty` or downcast variant corresponding to that projection.
199    /// The `handle_field` callback must map a `FieldIdx` to its `Ty`,
200    /// (which should be trivial when `T` = `Ty`).
201    pub fn projection_ty_core<V, T>(
202        self,
203        tcx: TyCtxt<'tcx>,
204        elem: &ProjectionElem<V, T>,
205        // FIXME(#155345): This should take `Unnormalized` as input and only
206        // normalize when actually required.
207        mut structurally_normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
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: ::std::fmt::Debug,
213        T: ::std::fmt::Debug + Copy,
214    {
215        if self.variant_index.is_some() && !#[allow(non_exhaustive_omitted_patterns)] match elem {
    ProjectionElem::Field(..) => true,
    _ => false,
}matches!(elem, ProjectionElem::Field(..)) {
216            crate::util::bug::bug_fmt(format_args!("cannot use non field projection on downcasted place"))bug!("cannot use non field projection on downcasted place")
217        }
218        let answer = match *elem {
219            ProjectionElem::Deref => {
220                let ty = structurally_normalize(self.ty).builtin_deref(true).unwrap_or_else(|| {
221                    crate::util::bug::bug_fmt(format_args!("deref projection of non-dereferenceable ty {0:?}",
        self))bug!("deref projection of non-dereferenceable ty {:?}", self)
222                });
223                PlaceTy::from_ty(ty)
224            }
225            ProjectionElem::Index(_) | ProjectionElem::ConstantIndex { .. } => {
226                PlaceTy::from_ty(structurally_normalize(self.ty).builtin_index().unwrap())
227            }
228            ProjectionElem::Subslice { from, to, from_end } => {
229                PlaceTy::from_ty(match structurally_normalize(self.ty).kind() {
230                    ty::Slice(..) => self.ty,
231                    ty::Array(inner, _) if !from_end => Ty::new_array(tcx, *inner, to - from),
232                    ty::Array(inner, size) if from_end => {
233                        let size = size
234                            .try_to_target_usize(tcx)
235                            .expect("expected subslice projection on fixed-size array");
236                        let len = size - from - to;
237                        Ty::new_array(tcx, *inner, len)
238                    }
239                    _ => crate::util::bug::bug_fmt(format_args!("cannot subslice non-array type: `{0:?}`",
        self))bug!("cannot subslice non-array type: `{:?}`", self),
240                })
241            }
242            ProjectionElem::Downcast(_name, index) => {
243                PlaceTy { ty: self.ty, variant_index: Some(index) }
244            }
245            ProjectionElem::Field(f, fty) => PlaceTy::from_ty(handle_field(
246                structurally_normalize(self.ty),
247                self.variant_index,
248                f,
249                fty,
250            )),
251            ProjectionElem::OpaqueCast(ty) => PlaceTy::from_ty(handle_opaque_cast_and_subtype(ty)),
252
253            // FIXME(unsafe_binders): Rename `handle_opaque_cast_and_subtype` to be more general.
254            ProjectionElem::UnwrapUnsafeBinder(ty) => {
255                PlaceTy::from_ty(handle_opaque_cast_and_subtype(ty))
256            }
257        };
258        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_middle/src/mir/statement.rs:258",
                        "rustc_middle::mir::statement", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/mir/statement.rs"),
                        ::tracing_core::__macro_support::Option::Some(258u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_middle::mir::statement"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::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(&format_args!("projection_ty self: {0:?} elem: {1:?} yields: {2:?}",
                                                    self, elem, answer) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("projection_ty self: {:?} elem: {:?} yields: {:?}", self, elem, answer);
259        answer
260    }
261}
262
263impl<V, T> ProjectionElem<V, T> {
264    /// Returns `true` if the target of this projection may refer to a different region of memory
265    /// than the base.
266    pub fn is_indirect(&self) -> bool {
267        match self {
268            Self::Deref => true,
269
270            Self::Field(_, _)
271            | Self::Index(_)
272            | Self::OpaqueCast(_)
273            | Self::ConstantIndex { .. }
274            | Self::Subslice { .. }
275            | Self::Downcast(_, _)
276            | Self::UnwrapUnsafeBinder(..) => false,
277        }
278    }
279
280    /// Returns `true` if the target of this projection always refers to the same memory region
281    /// whatever the state of the program.
282    pub fn is_stable_offset(&self) -> bool {
283        match self {
284            Self::Deref | Self::Index(_) => false,
285            Self::Field(_, _)
286            | Self::OpaqueCast(_)
287            | Self::ConstantIndex { .. }
288            | Self::Subslice { .. }
289            | Self::Downcast(_, _)
290            | Self::UnwrapUnsafeBinder(..) => true,
291        }
292    }
293
294    /// Returns `true` if this is a `Downcast` projection with the given `VariantIdx`.
295    pub fn is_downcast_to(&self, v: VariantIdx) -> bool {
296        #[allow(non_exhaustive_omitted_patterns)] match *self {
    Self::Downcast(_, x) if x == v => true,
    _ => false,
}matches!(*self, Self::Downcast(_, x) if x == v)
297    }
298
299    /// Returns `true` if this is a `Field` projection with the given index.
300    pub fn is_field_to(&self, f: FieldIdx) -> bool {
301        #[allow(non_exhaustive_omitted_patterns)] match *self {
    Self::Field(x, _) if x == f => true,
    _ => false,
}matches!(*self, Self::Field(x, _) if x == f)
302    }
303
304    /// Returns `true` if this is accepted inside `VarDebugInfoContents::Place`.
305    pub fn can_use_in_debuginfo(&self) -> bool {
306        match self {
307            Self::ConstantIndex { from_end: false, .. }
308            | Self::Deref
309            | Self::Downcast(_, _)
310            | Self::Field(_, _) => true,
311            Self::ConstantIndex { from_end: true, .. }
312            | Self::Index(_)
313            | Self::OpaqueCast(_)
314            | Self::Subslice { .. } => false,
315
316            // FIXME(unsafe_binders): Figure this out.
317            Self::UnwrapUnsafeBinder(..) => false,
318        }
319    }
320
321    /// Returns the `ProjectionKind` associated to this projection.
322    pub fn kind(self) -> ProjectionKind {
323        self.try_map(|_| Some(()), |_| ()).unwrap()
324    }
325
326    /// Apply functions to types and values in this projection and return the result.
327    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::Downcast(name, read_variant) => {
335                ProjectionElem::Downcast(name, read_variant)
336            }
337            ProjectionElem::Field(f, ty) => ProjectionElem::Field(f, t(ty)),
338            ProjectionElem::ConstantIndex { offset, min_length, from_end } => {
339                ProjectionElem::ConstantIndex { offset, min_length, from_end }
340            }
341            ProjectionElem::Subslice { from, to, from_end } => {
342                ProjectionElem::Subslice { from, to, from_end }
343            }
344            ProjectionElem::OpaqueCast(ty) => ProjectionElem::OpaqueCast(t(ty)),
345            ProjectionElem::UnwrapUnsafeBinder(ty) => ProjectionElem::UnwrapUnsafeBinder(t(ty)),
346            ProjectionElem::Index(val) => ProjectionElem::Index(v(val)?),
347        })
348    }
349}
350
351/// Alias for projections as they appear in `UserTypeProjection`, where we
352/// need neither the `V` parameter for `Index` nor the `T` for `Field`.
353pub type ProjectionKind = ProjectionElem<(), ()>;
354
355#[derive(#[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::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)]
356pub struct PlaceRef<'tcx> {
357    pub local: Local,
358    pub projection: &'tcx [PlaceElem<'tcx>],
359}
360
361// Once we stop implementing `Ord` for `DefId`,
362// this impl will be unnecessary. Until then, we'll
363// leave this impl in place to prevent re-adding a
364// dependency on the `Ord` impl for `DefId`
365impl<'tcx> !PartialOrd for PlaceRef<'tcx> {}
366
367impl<'tcx> Place<'tcx> {
368    // FIXME change this to a const fn by also making List::empty a const fn.
369    pub fn return_place() -> Place<'tcx> {
370        Place { local: RETURN_PLACE, projection: List::empty() }
371    }
372
373    /// Returns `true` if this `Place` contains a `Deref` projection.
374    ///
375    /// If `Place::is_indirect` returns false, the caller knows that the `Place` refers to the
376    /// same region of memory as its base.
377    pub fn is_indirect(&self) -> bool {
378        self.projection.iter().any(|elem| elem.is_indirect())
379    }
380
381    /// Returns `true` if the `Place` always refers to the same memory region
382    /// whatever the state of the program.
383    pub fn is_stable_offset(&self) -> bool {
384        self.projection.iter().all(|elem| elem.is_stable_offset())
385    }
386
387    /// Returns `true` if this `Place`'s first projection is `Deref`.
388    ///
389    /// This is useful because for MIR phases `AnalysisPhase::PostCleanup` and later,
390    /// `Deref` projections can only occur as the first projection. In that case this method
391    /// is equivalent to `is_indirect`, but faster.
392    pub fn is_indirect_first_projection(&self) -> bool {
393        self.as_ref().is_indirect_first_projection()
394    }
395
396    /// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
397    /// a single deref of a local.
398    #[inline(always)]
399    pub fn local_or_deref_local(&self) -> Option<Local> {
400        self.as_ref().local_or_deref_local()
401    }
402
403    /// If this place represents a local variable like `_X` with no
404    /// projections, return `Some(_X)`.
405    #[inline(always)]
406    pub fn as_local(&self) -> Option<Local> {
407        self.as_ref().as_local()
408    }
409
410    #[inline]
411    pub fn as_ref(&self) -> PlaceRef<'tcx> {
412        PlaceRef { local: self.local, projection: self.projection }
413    }
414
415    /// Iterate over the projections in evaluation order, i.e., the first element is the base with
416    /// its projection and then subsequently more projections are added.
417    /// As a concrete example, given the place a.b.c, this would yield:
418    /// - (a, .b)
419    /// - (a.b, .c)
420    ///
421    /// Given a place without projections, the iterator is empty.
422    #[inline]
423    pub fn iter_projections(
424        self,
425    ) -> impl Iterator<Item = (PlaceRef<'tcx>, PlaceElem<'tcx>)> + DoubleEndedIterator {
426        self.as_ref().iter_projections()
427    }
428
429    /// Generates a new place by appending `more_projections` to the existing ones
430    /// and interning the result.
431    pub fn project_deeper(self, more_projections: &[PlaceElem<'tcx>], tcx: TyCtxt<'tcx>) -> Self {
432        if more_projections.is_empty() {
433            return self;
434        }
435
436        self.as_ref().project_deeper(more_projections, tcx)
437    }
438
439    /// Return a place that projects to a field of the current place.
440    ///
441    /// The type of the current place must be an ADT.
442    pub fn project_to_field(
443        self,
444        idx: FieldIdx,
445        local_decls: &impl HasLocalDecls<'tcx>,
446        tcx: TyCtxt<'tcx>,
447    ) -> Self {
448        let ty = self.ty(local_decls, tcx).ty;
449        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}") };
450        let field = &adt.non_enum_variant().fields[idx];
451        let field_ty = field.ty(tcx, args).skip_norm_wip();
452        self.project_deeper(&[ProjectionElem::Field(idx, field_ty)], tcx)
453    }
454
455    pub fn ty_from<D>(
456        local: Local,
457        projection: &[PlaceElem<'tcx>],
458        local_decls: &D,
459        tcx: TyCtxt<'tcx>,
460    ) -> PlaceTy<'tcx>
461    where
462        D: ?Sized + HasLocalDecls<'tcx>,
463    {
464        // If there's a field projection element in `projection`, we *could* skip everything
465        // before that, but on 2026-01-31 a perf experiment showed no benefit from doing so.
466        PlaceTy::from_ty(local_decls.local_decls()[local].ty).multi_projection_ty(tcx, projection)
467    }
468
469    pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
470    where
471        D: HasLocalDecls<'tcx>,
472    {
473        Place::ty_from(self.local, self.projection, local_decls, tcx)
474    }
475}
476
477impl From<Local> for Place<'_> {
478    #[inline]
479    fn from(local: Local) -> Self {
480        Place { local, projection: List::empty() }
481    }
482}
483
484impl<'tcx> PlaceRef<'tcx> {
485    pub fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool {
486        self.local == other.local
487            && self.projection.len() <= other.projection.len()
488            && self.projection == &other.projection[..self.projection.len()]
489    }
490
491    /// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
492    /// a single deref of a local.
493    pub fn local_or_deref_local(&self) -> Option<Local> {
494        match *self {
495            PlaceRef { local, projection: [] }
496            | PlaceRef { local, projection: [ProjectionElem::Deref] } => Some(local),
497            _ => None,
498        }
499    }
500
501    /// Returns `true` if this `Place` contains a `Deref` projection.
502    ///
503    /// If `Place::is_indirect` returns false, the caller knows that the `Place` refers to the
504    /// same region of memory as its base.
505    pub fn is_indirect(&self) -> bool {
506        self.projection.iter().any(|elem| elem.is_indirect())
507    }
508
509    /// Returns `true` if this `Place`'s first projection is `Deref`.
510    ///
511    /// This is useful because for MIR phases `AnalysisPhase::PostCleanup` and later,
512    /// `Deref` projections can only occur as the first projection. In that case this method
513    /// is equivalent to `is_indirect`, but faster.
514    pub fn is_indirect_first_projection(&self) -> bool {
515        // To make sure this is not accidentally used in wrong mir phase
516        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!(
517            self.projection.is_empty() || !self.projection[1..].contains(&PlaceElem::Deref)
518        );
519        self.projection.first() == Some(&PlaceElem::Deref)
520    }
521
522    /// If this place represents a local variable like `_X` with no
523    /// projections, return `Some(_X)`.
524    #[inline]
525    pub fn as_local(&self) -> Option<Local> {
526        match *self {
527            PlaceRef { local, projection: [] } => Some(local),
528            _ => None,
529        }
530    }
531
532    #[inline]
533    pub fn to_place(&self, tcx: TyCtxt<'tcx>) -> Place<'tcx> {
534        Place { local: self.local, projection: tcx.mk_place_elems(self.projection) }
535    }
536
537    #[inline]
538    pub fn last_projection(&self) -> Option<(PlaceRef<'tcx>, PlaceElem<'tcx>)> {
539        if let &[ref proj_base @ .., elem] = self.projection {
540            Some((PlaceRef { local: self.local, projection: proj_base }, elem))
541        } else {
542            None
543        }
544    }
545
546    /// Iterate over the projections in evaluation order, i.e., the first element is the base with
547    /// its projection and then subsequently more projections are added.
548    /// As a concrete example, given the place a.b.c, this would yield:
549    /// - (a, .b)
550    /// - (a.b, .c)
551    ///
552    /// Given a place without projections, the iterator is empty.
553    #[inline]
554    pub fn iter_projections(
555        self,
556    ) -> impl Iterator<Item = (PlaceRef<'tcx>, PlaceElem<'tcx>)> + DoubleEndedIterator {
557        self.projection.iter().enumerate().map(move |(i, proj)| {
558            let base = PlaceRef { local: self.local, projection: &self.projection[..i] };
559            (base, *proj)
560        })
561    }
562
563    /// Return the place accessed locals that include the base local.
564    pub fn accessed_locals(self) -> impl Iterator<Item = Local> {
565        std::iter::once(self.local).chain(self.projection.iter().filter_map(|proj| match proj {
566            ProjectionElem::Index(local) => Some(*local),
567            ProjectionElem::Deref
568            | ProjectionElem::Field(_, _)
569            | ProjectionElem::ConstantIndex { .. }
570            | ProjectionElem::Subslice { .. }
571            | ProjectionElem::Downcast(_, _)
572            | ProjectionElem::OpaqueCast(_)
573            | ProjectionElem::UnwrapUnsafeBinder(_) => None,
574        }))
575    }
576
577    /// Generates a new place by appending `more_projections` to the existing ones
578    /// and interning the result.
579    pub fn project_deeper(
580        self,
581        more_projections: &[PlaceElem<'tcx>],
582        tcx: TyCtxt<'tcx>,
583    ) -> Place<'tcx> {
584        let mut v: Vec<PlaceElem<'tcx>>;
585
586        let new_projections = if self.projection.is_empty() {
587            more_projections
588        } else {
589            v = Vec::with_capacity(self.projection.len() + more_projections.len());
590            v.extend(self.projection);
591            v.extend(more_projections);
592            &v
593        };
594
595        Place { local: self.local, projection: tcx.mk_place_elems(new_projections) }
596    }
597
598    pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
599    where
600        D: ?Sized + HasLocalDecls<'tcx>,
601    {
602        Place::ty_from(self.local, self.projection, local_decls, tcx)
603    }
604}
605
606impl From<Local> for PlaceRef<'_> {
607    #[inline]
608    fn from(local: Local) -> Self {
609        PlaceRef { local, projection: &[] }
610    }
611}
612
613///////////////////////////////////////////////////////////////////////////
614// Operands
615
616impl<'tcx> Operand<'tcx> {
617    /// Convenience helper to make a constant that refers to the fn
618    /// with given `DefId` and args. Since this is used to synthesize
619    /// MIR, assumes `user_ty` is None.
620    pub fn function_handle(
621        tcx: TyCtxt<'tcx>,
622        def_id: DefId,
623        args: &[GenericArg<'tcx>],
624        span: Span,
625    ) -> Self {
626        Operand::zero_sized_constant(
627            tcx.type_of(def_id).instantiate(tcx, args).skip_norm_wip(),
628            span,
629        )
630    }
631
632    /// Convenience helper to make a constant that refers to the given `DefId` and args. Since this
633    /// is used to synthesize MIR, assumes `user_ty` is None.
634    pub fn unevaluated_constant(
635        tcx: TyCtxt<'tcx>,
636        def_id: DefId,
637        args: &[GenericArg<'tcx>],
638        span: Span,
639    ) -> Self {
640        let const_ = Const::from_unevaluated(tcx, def_id).instantiate(tcx, args).skip_norm_wip();
641        Operand::Constant(Box::new(ConstOperand { span, user_ty: None, const_ }))
642    }
643
644    /// Convenience helper to make a constant that refers to a zero-sized type.
645    pub fn zero_sized_constant(ty: Ty<'tcx>, span: Span) -> Self {
646        let const_ = Const::Val(ConstValue::ZeroSized, ty);
647        Operand::Constant(Box::new(ConstOperand { span, user_ty: None, const_ }))
648    }
649
650    pub fn is_move(&self) -> bool {
651        #[allow(non_exhaustive_omitted_patterns)] match self {
    Operand::Move(..) => true,
    _ => false,
}matches!(self, Operand::Move(..))
652    }
653
654    /// Convenience helper to make a literal-like constant from a given scalar value.
655    /// Since this is used to synthesize MIR, assumes `user_ty` is None.
656    pub fn const_from_scalar(
657        tcx: TyCtxt<'tcx>,
658        ty: Ty<'tcx>,
659        val: Scalar,
660        span: Span,
661    ) -> Operand<'tcx> {
662        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!({
663            let typing_env = ty::TypingEnv::fully_monomorphized();
664            let type_size = tcx
665                .layout_of(typing_env.as_query_input(ty))
666                .unwrap_or_else(|e| panic!("could not compute layout for {ty:?}: {e:?}"))
667                .size;
668            let scalar_size = match val {
669                Scalar::Int(int) => int.size(),
670                _ => panic!("Invalid scalar type {val:?}"),
671            };
672            scalar_size == type_size
673        });
674        Operand::Constant(Box::new(ConstOperand {
675            span,
676            user_ty: None,
677            const_: Const::Val(ConstValue::Scalar(val), ty),
678        }))
679    }
680
681    pub fn to_copy(&self) -> Self {
682        match *self {
683            Operand::Copy(_) | Operand::Constant(_) | Operand::RuntimeChecks(_) => self.clone(),
684            Operand::Move(place) => Operand::Copy(place),
685        }
686    }
687
688    /// Returns the `Place` that is the target of this `Operand`, or `None` if this `Operand` is a
689    /// constant.
690    pub fn place(&self) -> Option<Place<'tcx>> {
691        match self {
692            Operand::Copy(place) | Operand::Move(place) => Some(*place),
693            Operand::Constant(_) | Operand::RuntimeChecks(_) => None,
694        }
695    }
696
697    /// Returns the `ConstOperand` that is the target of this `Operand`, or `None` if this `Operand` is a
698    /// place.
699    pub fn constant(&self) -> Option<&ConstOperand<'tcx>> {
700        match self {
701            Operand::Constant(x) => Some(&**x),
702            Operand::Copy(_) | Operand::Move(_) | Operand::RuntimeChecks(_) => None,
703        }
704    }
705
706    /// Gets the `ty::FnDef` from an operand if it's a constant function item.
707    ///
708    /// While this is unlikely in general, it's the normal case of what you'll
709    /// find as the `func` in a [`TerminatorKind::Call`].
710    pub fn const_fn_def(&self) -> Option<(DefId, GenericArgsRef<'tcx>)> {
711        let const_ty = self.constant()?.const_.ty();
712        if let ty::FnDef(def_id, args) = *const_ty.kind() {
713            Some((def_id, args.no_bound_vars().unwrap()))
714        } else {
715            None
716        }
717    }
718
719    pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
720    where
721        D: ?Sized + HasLocalDecls<'tcx>,
722    {
723        match self {
724            &Operand::Copy(ref l) | &Operand::Move(ref l) => l.ty(local_decls, tcx).ty,
725            Operand::Constant(c) => c.const_.ty(),
726            Operand::RuntimeChecks(_) => tcx.types.bool,
727        }
728    }
729
730    pub fn span<D>(&self, local_decls: &D) -> Span
731    where
732        D: ?Sized + HasLocalDecls<'tcx>,
733    {
734        match self {
735            &Operand::Copy(ref l) | &Operand::Move(ref l) => {
736                local_decls.local_decls()[l.local].source_info.span
737            }
738            Operand::Constant(c) => c.span,
739            // User code should not contain this operand, so we should not need this span.
740            Operand::RuntimeChecks(_) => DUMMY_SP,
741        }
742    }
743}
744
745impl<'tcx> ConstOperand<'tcx> {
746    pub fn check_static_ptr(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
747        match self.const_.try_to_scalar() {
748            Some(Scalar::Ptr(ptr, _size)) => match tcx.global_alloc(ptr.provenance.alloc_id()) {
749                GlobalAlloc::Static(def_id) => {
750                    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));
751                    Some(def_id)
752                }
753                _ => None,
754            },
755            _ => None,
756        }
757    }
758
759    #[inline]
760    pub fn ty(&self) -> Ty<'tcx> {
761        self.const_.ty()
762    }
763}
764
765///////////////////////////////////////////////////////////////////////////
766// Rvalues
767
768impl<'tcx> Rvalue<'tcx> {
769    /// Returns true if rvalue can be safely removed when the result is unused.
770    #[inline]
771    pub fn is_safe_to_remove(&self) -> bool {
772        match self {
773            // Pointer to int casts may be side-effects due to exposing the provenance.
774            // While the model is undecided, we should be conservative. See
775            // <https://www.ralfj.de/blog/2022/04/11/provenance-exposed.html>
776            Rvalue::Cast(CastKind::PointerExposeProvenance, _, _) => false,
777
778            Rvalue::Use(_, _)
779            | Rvalue::CopyForDeref(_)
780            | Rvalue::Repeat(_, _)
781            | Rvalue::Ref(_, _, _)
782            | Rvalue::Reborrow(_, _, _)
783            | Rvalue::ThreadLocalRef(_)
784            | Rvalue::RawPtr(_, _)
785            | Rvalue::Cast(
786                CastKind::IntToInt
787                | CastKind::FloatToInt
788                | CastKind::FloatToFloat
789                | CastKind::IntToFloat
790                | CastKind::FnPtrToPtr
791                | CastKind::PtrToPtr
792                | CastKind::PointerCoercion(_, _)
793                | CastKind::PointerWithExposedProvenance
794                | CastKind::Transmute
795                | CastKind::Subtype,
796                _,
797                _,
798            )
799            | Rvalue::BinaryOp(_, _)
800            | Rvalue::UnaryOp(_, _)
801            | Rvalue::Discriminant(_)
802            | Rvalue::Aggregate(_, _)
803            | Rvalue::WrapUnsafeBinder(_, _) => true,
804        }
805    }
806
807    /// Returns true if rvalue is a generic Reborrow coercion (usage of Reborrow or CoerceShared
808    /// trait).
809    pub fn is_generic_reborrow(&self) -> bool {
810        #[allow(non_exhaustive_omitted_patterns)] match self {
    Self::Reborrow(..) => true,
    _ => false,
}matches!(self, Self::Reborrow(..))
811    }
812
813    pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
814    where
815        D: ?Sized + HasLocalDecls<'tcx>,
816    {
817        match *self {
818            Rvalue::Use(ref operand, _) => operand.ty(local_decls, tcx),
819            Rvalue::Repeat(ref operand, count) => {
820                Ty::new_array_with_const_len(tcx, operand.ty(local_decls, tcx), count)
821            }
822            Rvalue::ThreadLocalRef(did) => tcx.thread_local_ptr_ty(did),
823            Rvalue::Ref(reg, bk, ref place) => {
824                let place_ty = place.ty(local_decls, tcx).ty;
825                Ty::new_ref(tcx, reg, place_ty, bk.to_mutbl_lossy())
826            }
827            Rvalue::Reborrow(target, _, _) => target,
828            Rvalue::RawPtr(kind, ref place) => {
829                let place_ty = place.ty(local_decls, tcx).ty;
830                Ty::new_ptr(tcx, place_ty, kind.to_mutbl_lossy())
831            }
832            Rvalue::Cast(.., ty) => ty,
833            Rvalue::BinaryOp(op, (ref lhs, ref rhs)) => {
834                let lhs_ty = lhs.ty(local_decls, tcx);
835                let rhs_ty = rhs.ty(local_decls, tcx);
836                op.ty(tcx, lhs_ty, rhs_ty)
837            }
838            Rvalue::UnaryOp(op, ref operand) => {
839                let arg_ty = operand.ty(local_decls, tcx);
840                op.ty(tcx, arg_ty)
841            }
842            Rvalue::Discriminant(ref place) => place.ty(local_decls, tcx).ty.discriminant_ty(tcx),
843            Rvalue::Aggregate(ref ak, ref ops) => match **ak {
844                AggregateKind::Array(ty) => Ty::new_array(tcx, ty, ops.len() as u64),
845                AggregateKind::Tuple => {
846                    Ty::new_tup_from_iter(tcx, ops.iter().map(|op| op.ty(local_decls, tcx)))
847                }
848                AggregateKind::Adt(did, _, args, _, _) => {
849                    tcx.type_of(did).instantiate(tcx, args).skip_norm_wip()
850                }
851                AggregateKind::Closure(did, args) => Ty::new_closure(tcx, did, args),
852                AggregateKind::Coroutine(did, args) => Ty::new_coroutine(tcx, did, args),
853                AggregateKind::CoroutineClosure(did, args) => {
854                    Ty::new_coroutine_closure(tcx, did, args)
855                }
856                AggregateKind::RawPtr(ty, mutability) => Ty::new_ptr(tcx, ty, mutability),
857            },
858            Rvalue::CopyForDeref(ref place) => place.ty(local_decls, tcx).ty,
859            Rvalue::WrapUnsafeBinder(_, ty) => ty,
860        }
861    }
862}
863
864impl BorrowKind {
865    pub fn mutability(&self) -> Mutability {
866        match *self {
867            BorrowKind::Shared | BorrowKind::Fake(_) => Mutability::Not,
868            BorrowKind::Mut { .. } => Mutability::Mut,
869        }
870    }
871
872    /// Returns whether borrows represented by this kind are allowed to be split into separate
873    /// Reservation and Activation phases.
874    pub fn is_two_phase_borrow(&self) -> bool {
875        match *self {
876            BorrowKind::Shared
877            | BorrowKind::Fake(_)
878            | BorrowKind::Mut { kind: MutBorrowKind::Default | MutBorrowKind::ClosureCapture } => {
879                false
880            }
881            BorrowKind::Mut { kind: MutBorrowKind::TwoPhaseBorrow } => true,
882        }
883    }
884
885    pub fn to_mutbl_lossy(self) -> hir::Mutability {
886        match self {
887            BorrowKind::Mut { .. } => hir::Mutability::Mut,
888            BorrowKind::Shared => hir::Mutability::Not,
889
890            // We have no type corresponding to a shallow borrow, so use
891            // `&` as an approximation.
892            BorrowKind::Fake(_) => hir::Mutability::Not,
893        }
894    }
895}
896
897impl<'tcx> UnOp {
898    pub fn ty(&self, tcx: TyCtxt<'tcx>, arg_ty: Ty<'tcx>) -> Ty<'tcx> {
899        match self {
900            UnOp::Not | UnOp::Neg => arg_ty,
901            UnOp::PtrMetadata => arg_ty.pointee_metadata_ty_or_projection(tcx),
902        }
903    }
904}
905
906impl<'tcx> BinOp {
907    pub fn ty(&self, tcx: TyCtxt<'tcx>, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>) -> Ty<'tcx> {
908        // FIXME: handle SIMD correctly
909        match self {
910            &BinOp::Add
911            | &BinOp::AddUnchecked
912            | &BinOp::Sub
913            | &BinOp::SubUnchecked
914            | &BinOp::Mul
915            | &BinOp::MulUnchecked
916            | &BinOp::Div
917            | &BinOp::Rem
918            | &BinOp::BitXor
919            | &BinOp::BitAnd
920            | &BinOp::BitOr => {
921                // these should be integers or floats of the same size.
922                {
    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);
923                lhs_ty
924            }
925            &BinOp::AddWithOverflow | &BinOp::SubWithOverflow | &BinOp::MulWithOverflow => {
926                // these should be integers of the same size.
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);
928                Ty::new_tup(tcx, &[lhs_ty, tcx.types.bool])
929            }
930            &BinOp::Shl
931            | &BinOp::ShlUnchecked
932            | &BinOp::Shr
933            | &BinOp::ShrUnchecked
934            | &BinOp::Offset => {
935                lhs_ty // lhs_ty can be != rhs_ty
936            }
937            &BinOp::Eq | &BinOp::Lt | &BinOp::Le | &BinOp::Ne | &BinOp::Ge | &BinOp::Gt => {
938                tcx.types.bool
939            }
940            &BinOp::Cmp => {
941                // these should be integer-like types of the same size.
942                {
    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);
943                tcx.ty_ordering_enum(DUMMY_SP)
944            }
945        }
946    }
947    pub(crate) fn to_hir_binop(self) -> hir::BinOpKind {
948        match self {
949            // HIR `+`/`-`/`*` can map to either of these MIR BinOp, depending
950            // on whether overflow checks are enabled or not.
951            BinOp::Add | BinOp::AddWithOverflow => hir::BinOpKind::Add,
952            BinOp::Sub | BinOp::SubWithOverflow => hir::BinOpKind::Sub,
953            BinOp::Mul | BinOp::MulWithOverflow => hir::BinOpKind::Mul,
954            BinOp::Div => hir::BinOpKind::Div,
955            BinOp::Rem => hir::BinOpKind::Rem,
956            BinOp::BitXor => hir::BinOpKind::BitXor,
957            BinOp::BitAnd => hir::BinOpKind::BitAnd,
958            BinOp::BitOr => hir::BinOpKind::BitOr,
959            BinOp::Shl => hir::BinOpKind::Shl,
960            BinOp::Shr => hir::BinOpKind::Shr,
961            BinOp::Eq => hir::BinOpKind::Eq,
962            BinOp::Ne => hir::BinOpKind::Ne,
963            BinOp::Lt => hir::BinOpKind::Lt,
964            BinOp::Gt => hir::BinOpKind::Gt,
965            BinOp::Le => hir::BinOpKind::Le,
966            BinOp::Ge => hir::BinOpKind::Ge,
967            // We don't have HIR syntax for these.
968            BinOp::Cmp
969            | BinOp::AddUnchecked
970            | BinOp::SubUnchecked
971            | BinOp::MulUnchecked
972            | BinOp::ShlUnchecked
973            | BinOp::ShrUnchecked
974            | BinOp::Offset => {
975                ::core::panicking::panic("internal error: entered unreachable code")unreachable!()
976            }
977        }
978    }
979
980    /// If this is a `FooWithOverflow`, return `Some(Foo)`.
981    pub fn overflowing_to_wrapping(self) -> Option<BinOp> {
982        Some(match self {
983            BinOp::AddWithOverflow => BinOp::Add,
984            BinOp::SubWithOverflow => BinOp::Sub,
985            BinOp::MulWithOverflow => BinOp::Mul,
986            _ => return None,
987        })
988    }
989
990    /// Returns whether this is a `FooWithOverflow`
991    pub fn is_overflowing(self) -> bool {
992        self.overflowing_to_wrapping().is_some()
993    }
994
995    /// If this is a `Foo`, return `Some(FooWithOverflow)`.
996    pub fn wrapping_to_overflowing(self) -> Option<BinOp> {
997        Some(match self {
998            BinOp::Add => BinOp::AddWithOverflow,
999            BinOp::Sub => BinOp::SubWithOverflow,
1000            BinOp::Mul => BinOp::MulWithOverflow,
1001            _ => return None,
1002        })
1003    }
1004}
1005
1006impl From<Mutability> for RawPtrKind {
1007    fn from(other: Mutability) -> Self {
1008        match other {
1009            Mutability::Mut => RawPtrKind::Mut,
1010            Mutability::Not => RawPtrKind::Const,
1011        }
1012    }
1013}
1014
1015impl RawPtrKind {
1016    pub fn is_fake(self) -> bool {
1017        match self {
1018            RawPtrKind::Mut | RawPtrKind::Const => false,
1019            RawPtrKind::FakeForPtrMetadata => true,
1020        }
1021    }
1022
1023    pub fn to_mutbl_lossy(self) -> Mutability {
1024        match self {
1025            RawPtrKind::Mut => Mutability::Mut,
1026            RawPtrKind::Const => Mutability::Not,
1027
1028            // We have no type corresponding to a fake borrow, so use
1029            // `*const` as an approximation.
1030            RawPtrKind::FakeForPtrMetadata => Mutability::Not,
1031        }
1032    }
1033
1034    pub fn ptr_str(self) -> &'static str {
1035        match self {
1036            RawPtrKind::Mut => "mut",
1037            RawPtrKind::Const => "const",
1038            RawPtrKind::FakeForPtrMetadata => "const (fake)",
1039        }
1040    }
1041}
1042
1043// FIXME(panstromek)
1044//  I'd like to use real ThinVec here, but it fails to borrow check,
1045//  probably because ThinVec doesn't have #[may_dangle] on Drop impl?
1046type ThinVec<T> = Option<Box<Vec<T>>>;
1047
1048// This collection is almost always empty, so we
1049// use thin representation and optimize all methods
1050// for that by inlining the empty check
1051// and outlining the rest.
1052#[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) {
                match *self {
                    StmtDebugInfos(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 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)]
1053pub struct StmtDebugInfos<'tcx>(ThinVec<StmtDebugInfo<'tcx>>);
1054
1055impl<'tcx> StmtDebugInfos<'tcx> {
1056    pub fn push(&mut self, debuginfo: StmtDebugInfo<'tcx>) {
1057        self.0.get_or_insert_default().push(debuginfo);
1058    }
1059    #[inline]
1060    pub fn drop_debuginfo(&mut self) {
1061        match &mut self.0 {
1062            None => (),
1063            Some(v) => outline(move || v.clear()),
1064        }
1065    }
1066
1067    #[inline]
1068    pub fn is_empty(&self) -> bool {
1069        match &self.0 {
1070            None => true,
1071            Some(v) => outline(move || v.is_empty()),
1072        }
1073    }
1074    #[inline]
1075    pub fn prepend(&mut self, debuginfos: &mut Self) {
1076        if debuginfos.is_empty() {
1077            return;
1078        };
1079        outline(move || {
1080            debuginfos.append(self);
1081            std::mem::swap(debuginfos, self);
1082        })
1083    }
1084    #[inline]
1085    pub fn append(&mut self, debuginfos: &mut Self) {
1086        if debuginfos.is_empty() {
1087            return;
1088        };
1089        outline(move || {
1090            self.0.get_or_insert_default().append(debuginfos.0.as_mut().unwrap().as_mut())
1091        });
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}