1 use crate::ty::subst::SubstsRef;
2 use crate::ty::{CanonicalUserTypeAnnotation, Ty};
10 // There are two visitors, one for immutable and one for mutable references,
11 // but both are generated by the following macro. The code is written according
12 // to the following conventions:
14 // - introduce a `visit_foo` and a `super_foo` method for every MIR type
15 // - `visit_foo`, by default, calls `super_foo`
16 // - `super_foo`, by default, destructures the `foo` and calls `visit_foo`
18 // This allows you as a user to override `visit_foo` for types are
19 // interested in, and invoke (within that method) call
20 // `self.super_foo` to get the default behavior. Just as in an OO
21 // language, you should never call `super` methods ordinarily except
22 // in that circumstance.
24 // For the most part, we do not destructure things external to the
25 // MIR, e.g., types, spans, etc, but simply visit them and stop. This
26 // avoids duplication with other visitors like `TypeFoldable`.
30 // The code is written in a very deliberate style intended to minimize
31 // the chance of things being overlooked. You'll notice that we always
32 // use pattern matching to reference fields and we ensure that all
33 // matches are exhaustive.
35 // For example, the `super_basic_block_data` method begins like this:
38 // fn super_basic_block_data(&mut self,
40 // data: & $($mutability)? BasicBlockData<'tcx>) {
41 // let BasicBlockData {
47 // for statement in statements {
48 // self.visit_statement(block, statement);
55 // Here we used `let BasicBlockData { <fields> } = *data` deliberately,
56 // rather than writing `data.statements` in the body. This is because if one
57 // adds a new field to `BasicBlockData`, one will be forced to revise this code,
58 // and hence one will (hopefully) invoke the correct visit methods (if any).
60 // For this to work, ALL MATCHES MUST BE EXHAUSTIVE IN FIELDS AND VARIANTS.
61 // That means you never write `..` to skip over fields, nor do you write `_`
62 // to skip over variants in a `match`.
64 // The only place that `_` is acceptable is to match a field (or
65 // variant argument) that does not require visiting, as in
66 // `is_cleanup` above.
68 macro_rules! make_mir_visitor {
69 ($visitor_trait_name:ident, $($mutability:ident)?) => {
70 pub trait $visitor_trait_name<'tcx> {
71 // Override these, and call `self.super_xxx` to revert back to the
74 fn visit_body(&mut self, body: & $($mutability)? Body<'tcx>) {
75 self.super_body(body);
78 fn visit_basic_block_data(&mut self,
80 data: & $($mutability)? BasicBlockData<'tcx>) {
81 self.super_basic_block_data(block, data);
84 fn visit_source_scope_data(&mut self,
85 scope_data: & $($mutability)? SourceScopeData) {
86 self.super_source_scope_data(scope_data);
89 fn visit_statement(&mut self,
90 statement: & $($mutability)? Statement<'tcx>,
92 self.super_statement(statement, location);
95 fn visit_assign(&mut self,
96 place: & $($mutability)? Place<'tcx>,
97 rvalue: & $($mutability)? Rvalue<'tcx>,
99 self.super_assign(place, rvalue, location);
102 fn visit_terminator(&mut self,
103 terminator: & $($mutability)? Terminator<'tcx>,
104 location: Location) {
105 self.super_terminator(terminator, location);
108 fn visit_terminator_kind(&mut self,
109 kind: & $($mutability)? TerminatorKind<'tcx>,
110 location: Location) {
111 self.super_terminator_kind(kind, location);
114 fn visit_assert_message(&mut self,
115 msg: & $($mutability)? AssertMessage<'tcx>,
116 location: Location) {
117 self.super_assert_message(msg, location);
120 fn visit_rvalue(&mut self,
121 rvalue: & $($mutability)? Rvalue<'tcx>,
122 location: Location) {
123 self.super_rvalue(rvalue, location);
126 fn visit_operand(&mut self,
127 operand: & $($mutability)? Operand<'tcx>,
128 location: Location) {
129 self.super_operand(operand, location);
132 fn visit_ascribe_user_ty(&mut self,
133 place: & $($mutability)? Place<'tcx>,
134 variance: & $($mutability)? ty::Variance,
135 user_ty: & $($mutability)? UserTypeProjection,
136 location: Location) {
137 self.super_ascribe_user_ty(place, variance, user_ty, location);
140 fn visit_retag(&mut self,
141 kind: & $($mutability)? RetagKind,
142 place: & $($mutability)? Place<'tcx>,
143 location: Location) {
144 self.super_retag(kind, place, location);
147 fn visit_place(&mut self,
148 place: & $($mutability)? Place<'tcx>,
149 context: PlaceContext,
150 location: Location) {
151 self.super_place(place, context, location);
154 fn visit_place_base(&mut self,
155 base: & $($mutability)? PlaceBase<'tcx>,
156 context: PlaceContext,
157 location: Location) {
158 self.super_place_base(base, context, location);
161 visit_place_fns!($($mutability)?);
163 fn visit_constant(&mut self,
164 constant: & $($mutability)? Constant<'tcx>,
165 location: Location) {
166 self.super_constant(constant, location);
169 fn visit_span(&mut self,
170 span: & $($mutability)? Span) {
171 self.super_span(span);
174 fn visit_source_info(&mut self,
175 source_info: & $($mutability)? SourceInfo) {
176 self.super_source_info(source_info);
179 fn visit_ty(&mut self,
180 ty: $(& $mutability)? Ty<'tcx>,
185 fn visit_user_type_projection(
187 ty: & $($mutability)? UserTypeProjection,
189 self.super_user_type_projection(ty);
192 fn visit_user_type_annotation(
194 index: UserTypeAnnotationIndex,
195 ty: & $($mutability)? CanonicalUserTypeAnnotation<'tcx>,
197 self.super_user_type_annotation(index, ty);
200 fn visit_region(&mut self,
201 region: & $($mutability)? ty::Region<'tcx>,
203 self.super_region(region);
206 fn visit_const(&mut self,
207 constant: & $($mutability)? &'tcx ty::Const<'tcx>,
209 self.super_const(constant);
212 fn visit_substs(&mut self,
213 substs: & $($mutability)? SubstsRef<'tcx>,
215 self.super_substs(substs);
218 fn visit_local_decl(&mut self,
220 local_decl: & $($mutability)? LocalDecl<'tcx>) {
221 self.super_local_decl(local, local_decl);
224 fn visit_local(&mut self,
225 _local: & $($mutability)? Local,
226 _context: PlaceContext,
227 _location: Location) {
230 fn visit_source_scope(&mut self,
231 scope: & $($mutability)? SourceScope) {
232 self.super_source_scope(scope);
235 // The `super_xxx` methods comprise the default behavior and are
236 // not meant to be overridden.
238 fn super_body(&mut self,
239 body: & $($mutability)? Body<'tcx>) {
240 if let Some(yield_ty) = &$($mutability)? body.yield_ty {
241 self.visit_ty(yield_ty, TyContext::YieldTy(SourceInfo {
243 scope: OUTERMOST_SOURCE_SCOPE,
247 // for best performance, we want to use an iterator rather
248 // than a for-loop, to avoid calling `body::Body::invalidate` for
250 macro_rules! basic_blocks {
251 (mut) => (body.basic_blocks_mut().iter_enumerated_mut());
252 () => (body.basic_blocks().iter_enumerated());
254 for (bb, data) in basic_blocks!($($mutability)?) {
255 self.visit_basic_block_data(bb, data);
258 for scope in &$($mutability)? body.source_scopes {
259 self.visit_source_scope_data(scope);
262 self.visit_ty(&$($mutability)? body.return_ty(), TyContext::ReturnTy(SourceInfo {
264 scope: OUTERMOST_SOURCE_SCOPE,
267 for local in body.local_decls.indices() {
268 self.visit_local_decl(local, & $($mutability)? body.local_decls[local]);
271 macro_rules! type_annotations {
272 (mut) => (body.user_type_annotations.iter_enumerated_mut());
273 () => (body.user_type_annotations.iter_enumerated());
276 for (index, annotation) in type_annotations!($($mutability)?) {
277 self.visit_user_type_annotation(
282 self.visit_span(&$($mutability)? body.span);
285 fn super_basic_block_data(&mut self,
287 data: & $($mutability)? BasicBlockData<'tcx>) {
295 for statement in statements {
296 let location = Location { block: block, statement_index: index };
297 self.visit_statement(statement, location);
301 if let Some(terminator) = terminator {
302 let location = Location { block: block, statement_index: index };
303 self.visit_terminator(terminator, location);
307 fn super_source_scope_data(&mut self, scope_data: & $($mutability)? SourceScopeData) {
308 let SourceScopeData {
313 self.visit_span(span);
314 if let Some(parent_scope) = parent_scope {
315 self.visit_source_scope(parent_scope);
319 fn super_statement(&mut self,
320 statement: & $($mutability)? Statement<'tcx>,
321 location: Location) {
327 self.visit_source_info(source_info);
329 StatementKind::Assign(
330 box(ref $($mutability)? place, ref $($mutability)? rvalue)
332 self.visit_assign(place, rvalue, location);
334 StatementKind::FakeRead(_, place) => {
337 PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect),
341 StatementKind::SetDiscriminant { place, .. } => {
344 PlaceContext::MutatingUse(MutatingUseContext::Store),
348 StatementKind::StorageLive(local) => {
351 PlaceContext::NonUse(NonUseContext::StorageLive),
355 StatementKind::StorageDead(local) => {
358 PlaceContext::NonUse(NonUseContext::StorageDead),
362 StatementKind::InlineAsm(asm) => {
363 for output in & $($mutability)? asm.outputs[..] {
366 PlaceContext::MutatingUse(MutatingUseContext::AsmOutput),
370 for (span, input) in & $($mutability)? asm.inputs[..] {
371 self.visit_span(span);
372 self.visit_operand(input, location);
375 StatementKind::Retag(kind, place) => {
376 self.visit_retag(kind, place, location);
378 StatementKind::AscribeUserType(
379 box(ref $($mutability)? place, ref $($mutability)? user_ty),
382 self.visit_ascribe_user_ty(place, variance, user_ty, location);
384 StatementKind::Nop => {}
388 fn super_assign(&mut self,
389 place: &$($mutability)? Place<'tcx>,
390 rvalue: &$($mutability)? Rvalue<'tcx>,
391 location: Location) {
394 PlaceContext::MutatingUse(MutatingUseContext::Store),
397 self.visit_rvalue(rvalue, location);
400 fn super_terminator(&mut self,
401 terminator: &$($mutability)? Terminator<'tcx>,
402 location: Location) {
403 let Terminator { source_info, kind } = terminator;
405 self.visit_source_info(source_info);
406 self.visit_terminator_kind(kind, location);
409 fn super_terminator_kind(&mut self,
410 kind: & $($mutability)? TerminatorKind<'tcx>,
411 source_location: Location) {
413 TerminatorKind::Goto { .. } |
414 TerminatorKind::Resume |
415 TerminatorKind::Abort |
416 TerminatorKind::Return |
417 TerminatorKind::GeneratorDrop |
418 TerminatorKind::Unreachable |
419 TerminatorKind::FalseEdges { .. } |
420 TerminatorKind::FalseUnwind { .. } => {
423 TerminatorKind::SwitchInt {
429 self.visit_operand(discr, source_location);
430 self.visit_ty(switch_ty, TyContext::Location(source_location));
433 TerminatorKind::Drop {
440 PlaceContext::MutatingUse(MutatingUseContext::Drop),
445 TerminatorKind::DropAndReplace {
453 PlaceContext::MutatingUse(MutatingUseContext::Drop),
456 self.visit_operand(value, source_location);
459 TerminatorKind::Call {
466 self.visit_operand(func, source_location);
468 self.visit_operand(arg, source_location);
470 if let Some((destination, _)) = destination {
473 PlaceContext::MutatingUse(MutatingUseContext::Call),
479 TerminatorKind::Assert {
486 self.visit_operand(cond, source_location);
487 self.visit_assert_message(msg, source_location);
490 TerminatorKind::Yield {
495 self.visit_operand(value, source_location);
501 fn super_assert_message(&mut self,
502 msg: & $($mutability)? AssertMessage<'tcx>,
503 location: Location) {
504 use crate::mir::interpret::PanicInfo::*;
506 BoundsCheck { len, index } => {
507 self.visit_operand(len, location);
508 self.visit_operand(index, location);
510 Panic { .. } | Overflow(_) | OverflowNeg | DivisionByZero | RemainderByZero |
511 GeneratorResumedAfterReturn | GeneratorResumedAfterPanic => {
517 fn super_rvalue(&mut self,
518 rvalue: & $($mutability)? Rvalue<'tcx>,
519 location: Location) {
521 Rvalue::Use(operand) => {
522 self.visit_operand(operand, location);
525 Rvalue::Repeat(value, _) => {
526 self.visit_operand(value, location);
529 Rvalue::Ref(r, bk, path) => {
530 self.visit_region(r, location);
532 BorrowKind::Shared => PlaceContext::NonMutatingUse(
533 NonMutatingUseContext::SharedBorrow
535 BorrowKind::Shallow => PlaceContext::NonMutatingUse(
536 NonMutatingUseContext::ShallowBorrow
538 BorrowKind::Unique => PlaceContext::NonMutatingUse(
539 NonMutatingUseContext::UniqueBorrow
541 BorrowKind::Mut { .. } =>
542 PlaceContext::MutatingUse(MutatingUseContext::Borrow),
544 self.visit_place(path, ctx, location);
547 Rvalue::Len(path) => {
550 PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect),
555 Rvalue::Cast(_cast_kind, operand, ty) => {
556 self.visit_operand(operand, location);
557 self.visit_ty(ty, TyContext::Location(location));
560 Rvalue::BinaryOp(_bin_op, lhs, rhs)
561 | Rvalue::CheckedBinaryOp(_bin_op, lhs, rhs) => {
562 self.visit_operand(lhs, location);
563 self.visit_operand(rhs, location);
566 Rvalue::UnaryOp(_un_op, op) => {
567 self.visit_operand(op, location);
570 Rvalue::Discriminant(place) => {
573 PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect),
578 Rvalue::NullaryOp(_op, ty) => {
579 self.visit_ty(ty, TyContext::Location(location));
582 Rvalue::Aggregate(kind, operands) => {
583 let kind = &$($mutability)? **kind;
585 AggregateKind::Array(ty) => {
586 self.visit_ty(ty, TyContext::Location(location));
588 AggregateKind::Tuple => {
597 self.visit_substs(substs, location);
599 AggregateKind::Closure(
603 self.visit_substs(closure_substs, location);
605 AggregateKind::Generator(
610 self.visit_substs(generator_substs, location);
614 for operand in operands {
615 self.visit_operand(operand, location);
621 fn super_operand(&mut self,
622 operand: & $($mutability)? Operand<'tcx>,
623 location: Location) {
625 Operand::Copy(place) => {
628 PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
632 Operand::Move(place) => {
635 PlaceContext::NonMutatingUse(NonMutatingUseContext::Move),
639 Operand::Constant(constant) => {
640 self.visit_constant(constant, location);
645 fn super_ascribe_user_ty(&mut self,
646 place: & $($mutability)? Place<'tcx>,
647 _variance: & $($mutability)? ty::Variance,
648 user_ty: & $($mutability)? UserTypeProjection,
649 location: Location) {
652 PlaceContext::NonUse(NonUseContext::AscribeUserTy),
655 self.visit_user_type_projection(user_ty);
658 fn super_retag(&mut self,
659 _kind: & $($mutability)? RetagKind,
660 place: & $($mutability)? Place<'tcx>,
661 location: Location) {
664 PlaceContext::MutatingUse(MutatingUseContext::Retag),
669 fn super_place_base(&mut self,
670 place_base: & $($mutability)? PlaceBase<'tcx>,
671 context: PlaceContext,
672 location: Location) {
674 PlaceBase::Local(local) => {
675 self.visit_local(local, context, location);
677 PlaceBase::Static(box Static { kind: _, ty, def_id: _ }) => {
678 self.visit_ty(& $($mutability)? *ty, TyContext::Location(location));
683 fn super_local_decl(&mut self,
685 local_decl: & $($mutability)? LocalDecl<'tcx>) {
698 self.visit_ty(ty, TyContext::LocalDecl {
700 source_info: *source_info,
702 for (user_ty, _) in & $($mutability)? user_ty.contents {
703 self.visit_user_type_projection(user_ty);
705 self.visit_source_info(source_info);
706 self.visit_source_scope(visibility_scope);
709 fn super_source_scope(&mut self,
710 _scope: & $($mutability)? SourceScope) {
713 fn super_constant(&mut self,
714 constant: & $($mutability)? Constant<'tcx>,
715 location: Location) {
722 self.visit_span(span);
723 drop(user_ty); // no visit method for this
724 self.visit_const(literal, location);
727 fn super_span(&mut self, _span: & $($mutability)? Span) {
730 fn super_source_info(&mut self, source_info: & $($mutability)? SourceInfo) {
736 self.visit_span(span);
737 self.visit_source_scope(scope);
740 fn super_user_type_projection(
742 _ty: & $($mutability)? UserTypeProjection,
746 fn super_user_type_annotation(
748 _index: UserTypeAnnotationIndex,
749 ty: & $($mutability)? CanonicalUserTypeAnnotation<'tcx>,
751 self.visit_span(& $($mutability)? ty.span);
752 self.visit_ty(& $($mutability)? ty.inferred_ty, TyContext::UserTy(ty.span));
755 fn super_ty(&mut self, _ty: $(& $mutability)? Ty<'tcx>) {
758 fn super_region(&mut self, _region: & $($mutability)? ty::Region<'tcx>) {
761 fn super_const(&mut self, _const: & $($mutability)? &'tcx ty::Const<'tcx>) {
764 fn super_substs(&mut self, _substs: & $($mutability)? SubstsRef<'tcx>) {
767 // Convenience methods
769 fn visit_location(&mut self, body: & $($mutability)? Body<'tcx>, location: Location) {
770 let basic_block = & $($mutability)? body[location.block];
771 if basic_block.statements.len() == location.statement_index {
772 if let Some(ref $($mutability)? terminator) = basic_block.terminator {
773 self.visit_terminator(terminator, location)
776 let statement = & $($mutability)?
777 basic_block.statements[location.statement_index];
778 self.visit_statement(statement, location)
785 macro_rules! visit_place_fns {
787 fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;
791 place: &mut Place<'tcx>,
792 context: PlaceContext,
795 self.visit_place_base(&mut place.base, context, location);
797 if let Some(new_projection) = self.process_projection(&place.projection) {
798 place.projection = self.tcx().intern_place_elems(&new_projection);
802 fn process_projection(
804 projection: &'a [PlaceElem<'tcx>],
805 ) -> Option<Vec<PlaceElem<'tcx>>> {
806 let mut projection = Cow::Borrowed(projection);
808 for i in 0..projection.len() {
809 if let Some(elem) = projection.get(i) {
810 if let Some(elem) = self.process_projection_elem(elem) {
811 // This converts the borrowed projection into `Cow::Owned(_)` and returns a
812 // clone of the projection so we can mutate and reintern later.
813 let vec = projection.to_mut();
820 Cow::Borrowed(_) => None,
821 Cow::Owned(vec) => Some(vec),
825 fn process_projection_elem(
827 _elem: &PlaceElem<'tcx>,
828 ) -> Option<PlaceElem<'tcx>> {
836 base: &PlaceBase<'tcx>,
837 projection: &[PlaceElem<'tcx>],
838 context: PlaceContext,
841 self.super_projection(base, projection, context, location);
844 fn visit_projection_elem(
846 base: &PlaceBase<'tcx>,
847 proj_base: &[PlaceElem<'tcx>],
848 elem: &PlaceElem<'tcx>,
849 context: PlaceContext,
852 self.super_projection_elem(base, proj_base, elem, context, location);
858 context: PlaceContext,
861 let mut context = context;
863 if !place.projection.is_empty() {
864 context = if context.is_mutating_use() {
865 PlaceContext::MutatingUse(MutatingUseContext::Projection)
867 PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
871 self.visit_place_base(&place.base, context, location);
873 self.visit_projection(&place.base,
881 base: &PlaceBase<'tcx>,
882 projection: &[PlaceElem<'tcx>],
883 context: PlaceContext,
886 let mut cursor = projection;
887 while let [proj_base @ .., elem] = cursor {
889 self.visit_projection_elem(base, cursor, elem, context, location);
893 fn super_projection_elem(
895 _base: &PlaceBase<'tcx>,
896 _proj_base: &[PlaceElem<'tcx>],
897 elem: &PlaceElem<'tcx>,
898 _context: PlaceContext,
902 ProjectionElem::Field(_field, ty) => {
903 self.visit_ty(ty, TyContext::Location(location));
905 ProjectionElem::Index(local) => {
908 PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
912 ProjectionElem::Deref |
913 ProjectionElem::Subslice { from: _, to: _ } |
914 ProjectionElem::ConstantIndex { offset: _,
917 ProjectionElem::Downcast(_, _) => {
924 make_mir_visitor!(Visitor,);
925 make_mir_visitor!(MutVisitor,mut);
927 pub trait MirVisitable<'tcx> {
928 fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>);
931 impl<'tcx> MirVisitable<'tcx> for Statement<'tcx> {
932 fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
934 visitor.visit_statement(self, location)
938 impl<'tcx> MirVisitable<'tcx> for Terminator<'tcx> {
939 fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
941 visitor.visit_terminator(self, location)
945 impl<'tcx> MirVisitable<'tcx> for Option<Terminator<'tcx>> {
946 fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
948 visitor.visit_terminator(self.as_ref().unwrap(), location)
952 /// Extra information passed to `visit_ty` and friends to give context
953 /// about where the type etc appears.
957 /// The index of the local variable we are visiting.
960 /// The source location where this local variable was declared.
961 source_info: SourceInfo,
964 /// The inferred type of a user type annotation.
967 /// The return type of the function.
968 ReturnTy(SourceInfo),
972 /// A type found at some location.
976 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
977 pub enum NonMutatingUseContext {
978 /// Being inspected in some way, like loading a len.
980 /// Consumed as part of an operand.
982 /// Consumed as part of an operand.
990 /// Used as base for another place, e.g., `x` in `x.y`. Will not mutate the place.
991 /// For example, the projection `x.y` is not marked as a mutation in these cases:
999 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
1000 pub enum MutatingUseContext {
1001 /// Appears as LHS of an assignment.
1003 /// Can often be treated as a `Store`, but needs to be separate because
1004 /// ASM is allowed to read outputs as well, so a `Store`-`AsmOutput` sequence
1005 /// cannot be simplified the way a `Store`-`Store` can be.
1007 /// Destination of a call.
1013 /// Used as base for another place, e.g., `x` in `x.y`. Could potentially mutate the place.
1014 /// For example, the projection `x.y` is marked as a mutation in these cases:
1020 /// Retagging, a "Stacked Borrows" shadow state operation
1024 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
1025 pub enum NonUseContext {
1026 /// Starting a storage live range.
1028 /// Ending a storage live range.
1030 /// User type annotation assertions for NLL.
1034 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
1035 pub enum PlaceContext {
1036 NonMutatingUse(NonMutatingUseContext),
1037 MutatingUse(MutatingUseContext),
1038 NonUse(NonUseContext),
1042 /// Returns `true` if this place context represents a drop.
1043 pub fn is_drop(&self) -> bool {
1045 PlaceContext::MutatingUse(MutatingUseContext::Drop) => true,
1050 /// Returns `true` if this place context represents a borrow.
1051 pub fn is_borrow(&self) -> bool {
1053 PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
1054 PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
1055 PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow) |
1056 PlaceContext::MutatingUse(MutatingUseContext::Borrow) => true,
1061 /// Returns `true` if this place context represents a storage live or storage dead marker.
1062 pub fn is_storage_marker(&self) -> bool {
1064 PlaceContext::NonUse(NonUseContext::StorageLive) |
1065 PlaceContext::NonUse(NonUseContext::StorageDead) => true,
1070 /// Returns `true` if this place context represents a storage live marker.
1071 pub fn is_storage_live_marker(&self) -> bool {
1073 PlaceContext::NonUse(NonUseContext::StorageLive) => true,
1078 /// Returns `true` if this place context represents a storage dead marker.
1079 pub fn is_storage_dead_marker(&self) -> bool {
1081 PlaceContext::NonUse(NonUseContext::StorageDead) => true,
1086 /// Returns `true` if this place context represents a use that potentially changes the value.
1087 pub fn is_mutating_use(&self) -> bool {
1089 PlaceContext::MutatingUse(..) => true,
1094 /// Returns `true` if this place context represents a use that does not change the value.
1095 pub fn is_nonmutating_use(&self) -> bool {
1097 PlaceContext::NonMutatingUse(..) => true,
1102 /// Returns `true` if this place context represents a use.
1103 pub fn is_use(&self) -> bool {
1105 PlaceContext::NonUse(..) => false,
1110 /// Returns `true` if this place context represents an assignment statement.
1111 pub fn is_place_assignment(&self) -> bool {
1113 PlaceContext::MutatingUse(MutatingUseContext::Store) |
1114 PlaceContext::MutatingUse(MutatingUseContext::Call) |
1115 PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) => true,