1 use crate::ty::subst::SubstsRef;
2 use crate::ty::{CanonicalUserTypeAnnotation, ClosureSubsts, GeneratorSubsts, 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 fn visit_projection(&mut self,
162 base: & $($mutability)? PlaceBase<'tcx>,
163 projection: & $($mutability)? [PlaceElem<'tcx>],
164 context: PlaceContext,
165 location: Location) {
166 self.super_projection(base, projection, context, location);
169 fn visit_constant(&mut self,
170 constant: & $($mutability)? Constant<'tcx>,
171 location: Location) {
172 self.super_constant(constant, location);
175 fn visit_span(&mut self,
176 span: & $($mutability)? Span) {
177 self.super_span(span);
180 fn visit_source_info(&mut self,
181 source_info: & $($mutability)? SourceInfo) {
182 self.super_source_info(source_info);
185 fn visit_ty(&mut self,
186 ty: $(& $mutability)? Ty<'tcx>,
191 fn visit_user_type_projection(
193 ty: & $($mutability)? UserTypeProjection,
195 self.super_user_type_projection(ty);
198 fn visit_user_type_annotation(
200 index: UserTypeAnnotationIndex,
201 ty: & $($mutability)? CanonicalUserTypeAnnotation<'tcx>,
203 self.super_user_type_annotation(index, ty);
206 fn visit_region(&mut self,
207 region: & $($mutability)? ty::Region<'tcx>,
209 self.super_region(region);
212 fn visit_const(&mut self,
213 constant: & $($mutability)? &'tcx ty::Const<'tcx>,
215 self.super_const(constant);
218 fn visit_substs(&mut self,
219 substs: & $($mutability)? SubstsRef<'tcx>,
221 self.super_substs(substs);
224 fn visit_closure_substs(&mut self,
225 substs: & $($mutability)? ClosureSubsts<'tcx>,
227 self.super_closure_substs(substs);
230 fn visit_generator_substs(&mut self,
231 substs: & $($mutability)? GeneratorSubsts<'tcx>,
233 self.super_generator_substs(substs);
236 fn visit_local_decl(&mut self,
238 local_decl: & $($mutability)? LocalDecl<'tcx>) {
239 self.super_local_decl(local, local_decl);
242 fn visit_local(&mut self,
243 _local: & $($mutability)? Local,
244 _context: PlaceContext,
245 _location: Location) {
248 fn visit_source_scope(&mut self,
249 scope: & $($mutability)? SourceScope) {
250 self.super_source_scope(scope);
253 // The `super_xxx` methods comprise the default behavior and are
254 // not meant to be overridden.
256 fn super_body(&mut self,
257 body: & $($mutability)? Body<'tcx>) {
258 if let Some(yield_ty) = &$($mutability)? body.yield_ty {
259 self.visit_ty(yield_ty, TyContext::YieldTy(SourceInfo {
261 scope: OUTERMOST_SOURCE_SCOPE,
265 // for best performance, we want to use an iterator rather
266 // than a for-loop, to avoid calling `body::Body::invalidate` for
268 macro_rules! basic_blocks {
269 (mut) => (body.basic_blocks_mut().iter_enumerated_mut());
270 () => (body.basic_blocks().iter_enumerated());
272 for (bb, data) in basic_blocks!($($mutability)?) {
273 self.visit_basic_block_data(bb, data);
276 for scope in &$($mutability)? body.source_scopes {
277 self.visit_source_scope_data(scope);
280 self.visit_ty(&$($mutability)? body.return_ty(), TyContext::ReturnTy(SourceInfo {
282 scope: OUTERMOST_SOURCE_SCOPE,
285 for local in body.local_decls.indices() {
286 self.visit_local_decl(local, & $($mutability)? body.local_decls[local]);
289 macro_rules! type_annotations {
290 (mut) => (body.user_type_annotations.iter_enumerated_mut());
291 () => (body.user_type_annotations.iter_enumerated());
294 for (index, annotation) in type_annotations!($($mutability)?) {
295 self.visit_user_type_annotation(
300 self.visit_span(&$($mutability)? body.span);
303 fn super_basic_block_data(&mut self,
305 data: & $($mutability)? BasicBlockData<'tcx>) {
313 for statement in statements {
314 let location = Location { block: block, statement_index: index };
315 self.visit_statement(statement, location);
319 if let Some(terminator) = terminator {
320 let location = Location { block: block, statement_index: index };
321 self.visit_terminator(terminator, location);
325 fn super_source_scope_data(&mut self, scope_data: & $($mutability)? SourceScopeData) {
326 let SourceScopeData {
331 self.visit_span(span);
332 if let Some(parent_scope) = parent_scope {
333 self.visit_source_scope(parent_scope);
337 fn super_statement(&mut self,
338 statement: & $($mutability)? Statement<'tcx>,
339 location: Location) {
345 self.visit_source_info(source_info);
347 StatementKind::Assign(
348 box(ref $($mutability)? place, ref $($mutability)? rvalue)
350 self.visit_assign(place, rvalue, location);
352 StatementKind::FakeRead(_, place) => {
355 PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect),
359 StatementKind::SetDiscriminant { place, .. } => {
362 PlaceContext::MutatingUse(MutatingUseContext::Store),
366 StatementKind::StorageLive(local) => {
369 PlaceContext::NonUse(NonUseContext::StorageLive),
373 StatementKind::StorageDead(local) => {
376 PlaceContext::NonUse(NonUseContext::StorageDead),
380 StatementKind::InlineAsm(asm) => {
381 for output in & $($mutability)? asm.outputs[..] {
384 PlaceContext::MutatingUse(MutatingUseContext::AsmOutput),
388 for (span, input) in & $($mutability)? asm.inputs[..] {
389 self.visit_span(span);
390 self.visit_operand(input, location);
393 StatementKind::Retag(kind, place) => {
394 self.visit_retag(kind, place, location);
396 StatementKind::AscribeUserType(
397 box(ref $($mutability)? place, ref $($mutability)? user_ty),
400 self.visit_ascribe_user_ty(place, variance, user_ty, location);
402 StatementKind::Nop => {}
406 fn super_assign(&mut self,
407 place: &$($mutability)? Place<'tcx>,
408 rvalue: &$($mutability)? Rvalue<'tcx>,
409 location: Location) {
412 PlaceContext::MutatingUse(MutatingUseContext::Store),
415 self.visit_rvalue(rvalue, location);
418 fn super_terminator(&mut self,
419 terminator: &$($mutability)? Terminator<'tcx>,
420 location: Location) {
421 let Terminator { source_info, kind } = terminator;
423 self.visit_source_info(source_info);
424 self.visit_terminator_kind(kind, location);
427 fn super_terminator_kind(&mut self,
428 kind: & $($mutability)? TerminatorKind<'tcx>,
429 source_location: Location) {
431 TerminatorKind::Goto { .. } |
432 TerminatorKind::Resume |
433 TerminatorKind::Abort |
434 TerminatorKind::Return |
435 TerminatorKind::GeneratorDrop |
436 TerminatorKind::Unreachable |
437 TerminatorKind::FalseEdges { .. } |
438 TerminatorKind::FalseUnwind { .. } => {
441 TerminatorKind::SwitchInt {
447 self.visit_operand(discr, source_location);
448 self.visit_ty(switch_ty, TyContext::Location(source_location));
451 TerminatorKind::Drop {
458 PlaceContext::MutatingUse(MutatingUseContext::Drop),
463 TerminatorKind::DropAndReplace {
471 PlaceContext::MutatingUse(MutatingUseContext::Drop),
474 self.visit_operand(value, source_location);
477 TerminatorKind::Call {
484 self.visit_operand(func, source_location);
486 self.visit_operand(arg, source_location);
488 if let Some((destination, _)) = destination {
491 PlaceContext::MutatingUse(MutatingUseContext::Call),
497 TerminatorKind::Assert {
504 self.visit_operand(cond, source_location);
505 self.visit_assert_message(msg, source_location);
508 TerminatorKind::Yield {
513 self.visit_operand(value, source_location);
519 fn super_assert_message(&mut self,
520 msg: & $($mutability)? AssertMessage<'tcx>,
521 location: Location) {
522 use crate::mir::interpret::PanicInfo::*;
524 BoundsCheck { len, index } => {
525 self.visit_operand(len, location);
526 self.visit_operand(index, location);
528 Panic { .. } | Overflow(_) | OverflowNeg | DivisionByZero | RemainderByZero |
529 GeneratorResumedAfterReturn | GeneratorResumedAfterPanic => {
535 fn super_rvalue(&mut self,
536 rvalue: & $($mutability)? Rvalue<'tcx>,
537 location: Location) {
539 Rvalue::Use(operand) => {
540 self.visit_operand(operand, location);
543 Rvalue::Repeat(value, _) => {
544 self.visit_operand(value, location);
547 Rvalue::Ref(r, bk, path) => {
548 self.visit_region(r, location);
550 BorrowKind::Shared => PlaceContext::NonMutatingUse(
551 NonMutatingUseContext::SharedBorrow
553 BorrowKind::Shallow => PlaceContext::NonMutatingUse(
554 NonMutatingUseContext::ShallowBorrow
556 BorrowKind::Unique => PlaceContext::NonMutatingUse(
557 NonMutatingUseContext::UniqueBorrow
559 BorrowKind::Mut { .. } =>
560 PlaceContext::MutatingUse(MutatingUseContext::Borrow),
562 self.visit_place(path, ctx, location);
565 Rvalue::Len(path) => {
568 PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect),
573 Rvalue::Cast(_cast_kind, operand, ty) => {
574 self.visit_operand(operand, location);
575 self.visit_ty(ty, TyContext::Location(location));
578 Rvalue::BinaryOp(_bin_op, lhs, rhs)
579 | Rvalue::CheckedBinaryOp(_bin_op, lhs, rhs) => {
580 self.visit_operand(lhs, location);
581 self.visit_operand(rhs, location);
584 Rvalue::UnaryOp(_un_op, op) => {
585 self.visit_operand(op, location);
588 Rvalue::Discriminant(place) => {
591 PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect),
596 Rvalue::NullaryOp(_op, ty) => {
597 self.visit_ty(ty, TyContext::Location(location));
600 Rvalue::Aggregate(kind, operands) => {
601 let kind = &$($mutability)? **kind;
603 AggregateKind::Array(ty) => {
604 self.visit_ty(ty, TyContext::Location(location));
606 AggregateKind::Tuple => {
615 self.visit_substs(substs, location);
617 AggregateKind::Closure(
621 self.visit_closure_substs(closure_substs, location);
623 AggregateKind::Generator(
628 self.visit_generator_substs(generator_substs, location);
632 for operand in operands {
633 self.visit_operand(operand, location);
639 fn super_operand(&mut self,
640 operand: & $($mutability)? Operand<'tcx>,
641 location: Location) {
643 Operand::Copy(place) => {
646 PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
650 Operand::Move(place) => {
653 PlaceContext::NonMutatingUse(NonMutatingUseContext::Move),
657 Operand::Constant(constant) => {
658 self.visit_constant(constant, location);
663 fn super_ascribe_user_ty(&mut self,
664 place: & $($mutability)? Place<'tcx>,
665 _variance: & $($mutability)? ty::Variance,
666 user_ty: & $($mutability)? UserTypeProjection,
667 location: Location) {
670 PlaceContext::NonUse(NonUseContext::AscribeUserTy),
673 self.visit_user_type_projection(user_ty);
676 fn super_retag(&mut self,
677 _kind: & $($mutability)? RetagKind,
678 place: & $($mutability)? Place<'tcx>,
679 location: Location) {
682 PlaceContext::MutatingUse(MutatingUseContext::Retag),
687 fn super_place(&mut self,
688 place: & $($mutability)? Place<'tcx>,
689 context: PlaceContext,
690 location: Location) {
691 let mut context = context;
693 if !place.projection.is_empty() {
694 context = if context.is_mutating_use() {
695 PlaceContext::MutatingUse(MutatingUseContext::Projection)
697 PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
701 self.visit_place_base(& $($mutability)? place.base, context, location);
703 self.visit_projection(& $($mutability)? place.base,
704 & $($mutability)? place.projection,
709 fn super_place_base(&mut self,
710 place_base: & $($mutability)? PlaceBase<'tcx>,
711 context: PlaceContext,
712 location: Location) {
714 PlaceBase::Local(local) => {
715 self.visit_local(local, context, location);
717 PlaceBase::Static(box Static { kind: _, ty, def_id: _ }) => {
718 self.visit_ty(& $($mutability)? *ty, TyContext::Location(location));
723 fn super_projection(&mut self,
724 base: & $($mutability)? PlaceBase<'tcx>,
725 projection: & $($mutability)? [PlaceElem<'tcx>],
726 context: PlaceContext,
727 location: Location) {
728 if let [proj_base @ .., elem] = projection {
729 self.visit_projection(base, proj_base, context, location);
732 ProjectionElem::Field(_field, ty) => {
733 self.visit_ty(ty, TyContext::Location(location));
735 ProjectionElem::Index(local) => {
738 PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
742 ProjectionElem::Deref |
743 ProjectionElem::Subslice { from: _, to: _ } |
744 ProjectionElem::ConstantIndex { offset: _,
747 ProjectionElem::Downcast(_, _) => {
753 fn super_local_decl(&mut self,
755 local_decl: & $($mutability)? LocalDecl<'tcx>) {
768 self.visit_ty(ty, TyContext::LocalDecl {
770 source_info: *source_info,
772 for (user_ty, _) in & $($mutability)? user_ty.contents {
773 self.visit_user_type_projection(user_ty);
775 self.visit_source_info(source_info);
776 self.visit_source_scope(visibility_scope);
779 fn super_source_scope(&mut self,
780 _scope: & $($mutability)? SourceScope) {
783 fn super_constant(&mut self,
784 constant: & $($mutability)? Constant<'tcx>,
785 location: Location) {
792 self.visit_span(span);
793 drop(user_ty); // no visit method for this
794 self.visit_const(literal, location);
797 fn super_span(&mut self, _span: & $($mutability)? Span) {
800 fn super_source_info(&mut self, source_info: & $($mutability)? SourceInfo) {
806 self.visit_span(span);
807 self.visit_source_scope(scope);
810 fn super_user_type_projection(
812 _ty: & $($mutability)? UserTypeProjection,
816 fn super_user_type_annotation(
818 _index: UserTypeAnnotationIndex,
819 ty: & $($mutability)? CanonicalUserTypeAnnotation<'tcx>,
821 self.visit_span(& $($mutability)? ty.span);
822 self.visit_ty(& $($mutability)? ty.inferred_ty, TyContext::UserTy(ty.span));
825 fn super_ty(&mut self, _ty: $(& $mutability)? Ty<'tcx>) {
828 fn super_region(&mut self, _region: & $($mutability)? ty::Region<'tcx>) {
831 fn super_const(&mut self, _const: & $($mutability)? &'tcx ty::Const<'tcx>) {
834 fn super_substs(&mut self, _substs: & $($mutability)? SubstsRef<'tcx>) {
837 fn super_generator_substs(&mut self,
838 _substs: & $($mutability)? GeneratorSubsts<'tcx>) {
841 fn super_closure_substs(&mut self,
842 _substs: & $($mutability)? ClosureSubsts<'tcx>) {
845 // Convenience methods
847 fn visit_location(&mut self, body: & $($mutability)? Body<'tcx>, location: Location) {
848 let basic_block = & $($mutability)? body[location.block];
849 if basic_block.statements.len() == location.statement_index {
850 if let Some(ref $($mutability)? terminator) = basic_block.terminator {
851 self.visit_terminator(terminator, location)
854 let statement = & $($mutability)?
855 basic_block.statements[location.statement_index];
856 self.visit_statement(statement, location)
863 make_mir_visitor!(Visitor,);
864 make_mir_visitor!(MutVisitor,mut);
866 pub trait MirVisitable<'tcx> {
867 fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>);
870 impl<'tcx> MirVisitable<'tcx> for Statement<'tcx> {
871 fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
873 visitor.visit_statement(self, location)
877 impl<'tcx> MirVisitable<'tcx> for Terminator<'tcx> {
878 fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
880 visitor.visit_terminator(self, location)
884 impl<'tcx> MirVisitable<'tcx> for Option<Terminator<'tcx>> {
885 fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
887 visitor.visit_terminator(self.as_ref().unwrap(), location)
891 /// Extra information passed to `visit_ty` and friends to give context
892 /// about where the type etc appears.
893 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
896 /// The index of the local variable we are visiting.
899 /// The source location where this local variable was declared.
900 source_info: SourceInfo,
903 /// The inferred type of a user type annotation.
906 /// The return type of the function.
907 ReturnTy(SourceInfo),
911 /// A type found at some location.
915 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
916 pub enum NonMutatingUseContext {
917 /// Being inspected in some way, like loading a len.
919 /// Consumed as part of an operand.
921 /// Consumed as part of an operand.
929 /// Used as base for another place, e.g., `x` in `x.y`. Will not mutate the place.
930 /// For example, the projection `x.y` is not marked as a mutation in these cases:
938 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
939 pub enum MutatingUseContext {
940 /// Appears as LHS of an assignment.
942 /// Can often be treated as a `Store`, but needs to be separate because
943 /// ASM is allowed to read outputs as well, so a `Store`-`AsmOutput` sequence
944 /// cannot be simplified the way a `Store`-`Store` can be.
946 /// Destination of a call.
952 /// Used as base for another place, e.g., `x` in `x.y`. Could potentially mutate the place.
953 /// For example, the projection `x.y` is marked as a mutation in these cases:
959 /// Retagging, a "Stacked Borrows" shadow state operation
963 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
964 pub enum NonUseContext {
965 /// Starting a storage live range.
967 /// Ending a storage live range.
969 /// User type annotation assertions for NLL.
973 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
974 pub enum PlaceContext {
975 NonMutatingUse(NonMutatingUseContext),
976 MutatingUse(MutatingUseContext),
977 NonUse(NonUseContext),
981 /// Returns `true` if this place context represents a drop.
982 pub fn is_drop(&self) -> bool {
984 PlaceContext::MutatingUse(MutatingUseContext::Drop) => true,
989 /// Returns `true` if this place context represents a borrow.
990 pub fn is_borrow(&self) -> bool {
992 PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
993 PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
994 PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow) |
995 PlaceContext::MutatingUse(MutatingUseContext::Borrow) => true,
1000 /// Returns `true` if this place context represents a storage live or storage dead marker.
1001 pub fn is_storage_marker(&self) -> bool {
1003 PlaceContext::NonUse(NonUseContext::StorageLive) |
1004 PlaceContext::NonUse(NonUseContext::StorageDead) => true,
1009 /// Returns `true` if this place context represents a storage live marker.
1010 pub fn is_storage_live_marker(&self) -> bool {
1012 PlaceContext::NonUse(NonUseContext::StorageLive) => true,
1017 /// Returns `true` if this place context represents a storage dead marker.
1018 pub fn is_storage_dead_marker(&self) -> bool {
1020 PlaceContext::NonUse(NonUseContext::StorageDead) => true,
1025 /// Returns `true` if this place context represents a use that potentially changes the value.
1026 pub fn is_mutating_use(&self) -> bool {
1028 PlaceContext::MutatingUse(..) => true,
1033 /// Returns `true` if this place context represents a use that does not change the value.
1034 pub fn is_nonmutating_use(&self) -> bool {
1036 PlaceContext::NonMutatingUse(..) => true,
1041 /// Returns `true` if this place context represents a use.
1042 pub fn is_use(&self) -> bool {
1044 PlaceContext::NonUse(..) => false,
1049 /// Returns `true` if this place context represents an assignment statement.
1050 pub fn is_place_assignment(&self) -> bool {
1052 PlaceContext::MutatingUse(MutatingUseContext::Store) |
1053 PlaceContext::MutatingUse(MutatingUseContext::Call) |
1054 PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) => true,