+use crate::mir::*;
use crate::ty::subst::SubstsRef;
use crate::ty::{CanonicalUserTypeAnnotation, Ty};
-use crate::mir::*;
-use syntax_pos::Span;
+use rustc_span::Span;
// # The MIR Visitor
//
self.visit_place(path, ctx, location);
}
+ Rvalue::AddressOf(m, path) => {
+ let ctx = match m {
+ Mutability::Mut => PlaceContext::MutatingUse(
+ MutatingUseContext::AddressOf
+ ),
+ Mutability::Not => PlaceContext::NonMutatingUse(
+ NonMutatingUseContext::AddressOf
+ ),
+ };
+ self.visit_place(path, ctx, location);
+ }
+
Rvalue::Len(path) => {
self.visit_place(
path,
PlaceBase::Local(local) => {
self.visit_local(local, context, location);
}
- PlaceBase::Static(box Static { kind: _, ty, def_id: _ }) => {
+ PlaceBase::Static(box Static { ty, def_id: _ }) => {
self.visit_ty(& $($mutability)? *ty, TyContext::Location(location));
}
}
);
}
ProjectionElem::Deref |
- ProjectionElem::Subslice { from: _, to: _ } |
+ ProjectionElem::Subslice { from: _, to: _, from_end: _ } |
ProjectionElem::ConstantIndex { offset: _,
min_length: _,
from_end: _ } |
}
make_mir_visitor!(Visitor,);
-make_mir_visitor!(MutVisitor,mut);
+make_mir_visitor!(MutVisitor, mut);
pub trait MirVisitable<'tcx> {
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>);
}
impl<'tcx> MirVisitable<'tcx> for Statement<'tcx> {
- fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
- {
+ fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>) {
visitor.visit_statement(self, location)
}
}
impl<'tcx> MirVisitable<'tcx> for Terminator<'tcx> {
- fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
- {
+ fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>) {
visitor.visit_terminator(self, location)
}
}
impl<'tcx> MirVisitable<'tcx> for Option<Terminator<'tcx>> {
- fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
- {
+ fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>) {
visitor.visit_terminator(self.as_ref().unwrap(), location)
}
}
ShallowBorrow,
/// Unique borrow.
UniqueBorrow,
+ /// AddressOf for *const pointer.
+ AddressOf,
/// Used as base for another place, e.g., `x` in `x.y`. Will not mutate the place.
/// For example, the projection `x.y` is not marked as a mutation in these cases:
///
Drop,
/// Mutable borrow.
Borrow,
+ /// AddressOf for *mut pointer.
+ AddressOf,
/// Used as base for another place, e.g., `x` in `x.y`. Could potentially mutate the place.
/// For example, the projection `x.y` is marked as a mutation in these cases:
///
/// Returns `true` if this place context represents a borrow.
pub fn is_borrow(&self) -> bool {
match *self {
- PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
- PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
- PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow) |
- PlaceContext::MutatingUse(MutatingUseContext::Borrow) => true,
+ PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow)
+ | PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow)
+ | PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow)
+ | PlaceContext::MutatingUse(MutatingUseContext::Borrow) => true,
_ => false,
}
}
/// Returns `true` if this place context represents a storage live or storage dead marker.
pub fn is_storage_marker(&self) -> bool {
match *self {
- PlaceContext::NonUse(NonUseContext::StorageLive) |
- PlaceContext::NonUse(NonUseContext::StorageDead) => true,
+ PlaceContext::NonUse(NonUseContext::StorageLive)
+ | PlaceContext::NonUse(NonUseContext::StorageDead) => true,
_ => false,
}
}
/// Returns `true` if this place context represents an assignment statement.
pub fn is_place_assignment(&self) -> bool {
match *self {
- PlaceContext::MutatingUse(MutatingUseContext::Store) |
- PlaceContext::MutatingUse(MutatingUseContext::Call) |
- PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) => true,
+ PlaceContext::MutatingUse(MutatingUseContext::Store)
+ | PlaceContext::MutatingUse(MutatingUseContext::Call)
+ | PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) => true,
_ => false,
}
}