Skip to main content

rustc_public/mir/
visit.rs

1//! # The rustc_public's IR Visitor
2//!
3//! ## Overview
4//!
5//! We currently only support an immutable visitor.
6//! The structure of this visitor is similar to the ones internal to `rustc`,
7//! and it follows the following conventions:
8//!
9//! For every mir item, the trait has a `visit_<item>` and a `super_<item>` method.
10//! - `visit_<item>`, by default, calls `super_<item>`
11//! - `super_<item>`, by default, destructures the `<item>` and calls `visit_<sub_item>` for
12//!   all sub-items that compose the original item.
13//!
14//! In order to implement a visitor, override the `visit_*` methods for the types you are
15//! interested in analyzing, and invoke (within that method call)
16//! `self.super_*` to continue to the traverse.
17//! Avoid calling `super` methods in other circumstances.
18//!
19//! For the most part, we do not destructure things external to the
20//! MIR, e.g., types, spans, etc, but simply visit them and stop.
21//! This avoids duplication with other visitors like `TypeFoldable`.
22//!
23//! ## Updating
24//!
25//! The code is written in a very deliberate style intended to minimize
26//! the chance of things being overlooked.
27//!
28//! Use pattern matching to reference fields and ensure that all
29//! matches are exhaustive.
30//!
31//! For this to work, ALL MATCHES MUST BE EXHAUSTIVE IN FIELDS AND VARIANTS.
32//! That means you never write `..` to skip over fields, nor do you write `_`
33//! to skip over variants in a `match`.
34//!
35//! The only place that `_` is acceptable is to match a field (or
36//! variant argument) that does not require visiting.
37
38use crate::mir::*;
39use crate::ty::{GenericArgs, MirConst, Region, Ty, TyConst};
40use crate::{Error, Opaque, Span};
41
42macro_rules! make_mir_visitor {
43    ($visitor_trait_name:ident, $($mutability:ident)?) => {
44        pub trait $visitor_trait_name {
45            fn visit_body(&mut self, body: &$($mutability)? Body) {
46                self.super_body(body)
47            }
48
49            fn visit_basic_block(&mut self, bb: &$($mutability)? BasicBlock) {
50                self.super_basic_block(bb)
51            }
52
53            fn visit_ret_decl(&mut self, local: Local, decl: &$($mutability)? LocalDecl) {
54                self.super_ret_decl(local, decl)
55            }
56
57            fn visit_arg_decl(&mut self, local: Local, decl: &$($mutability)? LocalDecl) {
58                self.super_arg_decl(local, decl)
59            }
60
61            fn visit_local_decl(&mut self, local: Local, decl: &$($mutability)? LocalDecl) {
62                self.super_local_decl(local, decl)
63            }
64
65            fn visit_statement(&mut self, stmt: &$($mutability)? Statement, location: Location) {
66                self.super_statement(stmt, location)
67            }
68
69            fn visit_terminator(&mut self, term: &$($mutability)? Terminator, location: Location) {
70                self.super_terminator(term, location)
71            }
72
73            fn visit_span(&mut self, span: &$($mutability)? Span) {
74                self.super_span(span)
75            }
76
77            fn visit_place(&mut self, place: &$($mutability)? Place, ptx: PlaceContext, location: Location) {
78                self.super_place(place, ptx, location)
79            }
80
81            visit_place_fns!($($mutability)?);
82
83            fn visit_local(&mut self, local: &$($mutability)? Local, ptx: PlaceContext, location: Location) {
84                let _ = (local, ptx, location);
85            }
86
87            fn visit_rvalue(&mut self, rvalue: &$($mutability)? Rvalue, location: Location) {
88                self.super_rvalue(rvalue, location)
89            }
90
91            fn visit_operand(&mut self, operand: &$($mutability)? Operand, location: Location) {
92                self.super_operand(operand, location)
93            }
94
95            fn visit_user_type_projection(&mut self, projection: &$($mutability)? UserTypeProjection) {
96                self.super_user_type_projection(projection)
97            }
98
99            fn visit_ty(&mut self, ty: &$($mutability)? Ty, location: Location) {
100                let _ = location;
101                self.super_ty(ty)
102            }
103
104            fn visit_const_operand(&mut self, constant: &$($mutability)? ConstOperand, location: Location) {
105                self.super_const_operand(constant, location)
106            }
107
108            fn visit_mir_const(&mut self, constant: &$($mutability)? MirConst, location: Location) {
109                self.super_mir_const(constant, location)
110            }
111
112            fn visit_ty_const(&mut self, constant: &$($mutability)? TyConst, location: Location) {
113                let _ = location;
114                self.super_ty_const(constant)
115            }
116
117            fn visit_region(&mut self, region: &$($mutability)? Region, location: Location) {
118                let _ = location;
119                self.super_region(region)
120            }
121
122            fn visit_args(&mut self, args: &$($mutability)? GenericArgs, location: Location) {
123                let _ = location;
124                self.super_args(args)
125            }
126
127            fn visit_assert_msg(&mut self, msg: &$($mutability)? AssertMessage, location: Location) {
128                self.super_assert_msg(msg, location)
129            }
130
131            fn visit_var_debug_info(&mut self, var_debug_info: &$($mutability)? VarDebugInfo) {
132                self.super_var_debug_info(var_debug_info);
133            }
134
135            fn super_body(&mut self, body: &$($mutability)? Body) {
136                super_body!(self, body, $($mutability)?);
137            }
138
139            fn super_basic_block(&mut self, bb: &$($mutability)? BasicBlock) {
140                let BasicBlock { statements, terminator } = bb;
141                for stmt in statements {
142                    self.visit_statement(stmt, Location(stmt.span));
143                }
144                self.visit_terminator(terminator, Location(terminator.span));
145            }
146
147            fn super_local_decl(&mut self, local: Local, decl: &$($mutability)? LocalDecl) {
148                let _ = local;
149                let LocalDecl { ty, span, .. } = decl;
150                self.visit_ty(ty, Location(*span));
151            }
152
153            fn super_ret_decl(&mut self, local: Local, decl: &$($mutability)? LocalDecl) {
154                self.super_local_decl(local, decl)
155            }
156
157            fn super_arg_decl(&mut self, local: Local, decl: &$($mutability)? LocalDecl) {
158                self.super_local_decl(local, decl)
159            }
160
161            fn super_statement(&mut self, stmt: &$($mutability)? Statement, location: Location) {
162                let Statement { kind, span } = stmt;
163                self.visit_span(span);
164                match kind {
165                    StatementKind::Assign(place, rvalue) => {
166                        self.visit_place(place, PlaceContext::MUTATING, location);
167                        self.visit_rvalue(rvalue, location);
168                    }
169                    StatementKind::FakeRead(_, place) | StatementKind::PlaceMention(place) => {
170                        self.visit_place(place, PlaceContext::NON_MUTATING, location);
171                    }
172                    StatementKind::SetDiscriminant { place, .. }
173                    | StatementKind::Retag(_, place) => {
174                        self.visit_place(place, PlaceContext::MUTATING, location);
175                    }
176                    StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
177                        self.visit_local(local, PlaceContext::NON_USE, location);
178                    }
179                    StatementKind::AscribeUserType { place, projections, variance: _ } => {
180                        self.visit_place(place, PlaceContext::NON_USE, location);
181                        self.visit_user_type_projection(projections);
182                    }
183                    StatementKind::Coverage(coverage) => visit_opaque(coverage),
184                    StatementKind::Intrinsic(intrinsic) => match intrinsic {
185                        NonDivergingIntrinsic::Assume(operand) => {
186                            self.visit_operand(operand, location);
187                        }
188                        NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
189                            src,
190                            dst,
191                            count,
192                        }) => {
193                            self.visit_operand(src, location);
194                            self.visit_operand(dst, location);
195                            self.visit_operand(count, location);
196                        }
197                    },
198                    StatementKind::ConstEvalCounter | StatementKind::Nop => {}
199                }
200            }
201
202            fn super_terminator(&mut self, term: &$($mutability)? Terminator, location: Location) {
203                let Terminator { kind, span } = term;
204                self.visit_span(span);
205                match kind {
206                    TerminatorKind::Goto { .. }
207                    | TerminatorKind::Resume
208                    | TerminatorKind::Abort
209                    | TerminatorKind::Unreachable => {}
210                    TerminatorKind::Assert { cond, expected: _, msg, target: _, unwind: _ } => {
211                        self.visit_operand(cond, location);
212                        self.visit_assert_msg(msg, location);
213                    }
214                    TerminatorKind::Drop { place, target: _, unwind: _ } => {
215                        self.visit_place(place, PlaceContext::MUTATING, location);
216                    }
217                    TerminatorKind::Call { func, args, destination, target: _, unwind: _ } => {
218                        self.visit_operand(func, location);
219                        for arg in args {
220                            self.visit_operand(arg, location);
221                        }
222                        self.visit_place(destination, PlaceContext::MUTATING, location);
223                    }
224                    TerminatorKind::InlineAsm { operands, .. } => {
225                        for op in operands {
226                            let InlineAsmOperand { in_value, out_place, raw_rpr: _ } = op;
227                            if let Some(input) = in_value {
228                                self.visit_operand(input, location);
229                            }
230                            if let Some(output) = out_place {
231                                self.visit_place(output, PlaceContext::MUTATING, location);
232                            }
233                        }
234                    }
235                    TerminatorKind::Return => {
236                        let $($mutability)? local = RETURN_LOCAL;
237                        self.visit_local(&$($mutability)? local, PlaceContext::NON_MUTATING, location);
238                    }
239                    TerminatorKind::SwitchInt { discr, targets: _ } => {
240                        self.visit_operand(discr, location);
241                    }
242                }
243            }
244
245            fn super_span(&mut self, span: &$($mutability)? Span) {
246                let _ = span;
247            }
248
249            fn super_rvalue(&mut self, rvalue: &$($mutability)? Rvalue, location: Location) {
250                match rvalue {
251                    Rvalue::AddressOf(mutability, place) => {
252                        let pcx = PlaceContext { is_mut: *mutability == RawPtrKind::Mut };
253                        self.visit_place(place, pcx, location);
254                    }
255                    Rvalue::Aggregate(_, operands) => {
256                        for op in operands {
257                            self.visit_operand(op, location);
258                        }
259                    }
260                    Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => {
261                        self.visit_operand(lhs, location);
262                        self.visit_operand(rhs, location);
263                    }
264                    Rvalue::Cast(_, op, ty) => {
265                        self.visit_operand(op, location);
266                        self.visit_ty(ty, location);
267                    }
268                    Rvalue::CopyForDeref(place) | Rvalue::Discriminant(place) | Rvalue::Len(place) => {
269                        self.visit_place(place, PlaceContext::NON_MUTATING, location);
270                    }
271                    Rvalue::Ref(region, kind, place) => {
272                        self.visit_region(region, location);
273                        let pcx = PlaceContext { is_mut: matches!(kind, BorrowKind::Mut { .. }) };
274                        self.visit_place(place, pcx, location);
275                    }
276                    Rvalue::Repeat(op, constant) => {
277                        self.visit_operand(op, location);
278                        self.visit_ty_const(constant, location);
279                    }
280                    Rvalue::ThreadLocalRef(_) => {}
281                    Rvalue::UnaryOp(_, op) | Rvalue::Use(op) => {
282                        self.visit_operand(op, location);
283                    }
284                }
285            }
286
287            fn super_operand(&mut self, operand: &$($mutability)? Operand, location: Location) {
288                match operand {
289                    Operand::Copy(place) | Operand::Move(place) => {
290                        self.visit_place(place, PlaceContext::NON_MUTATING, location)
291                    }
292                    Operand::Constant(constant) => {
293                        self.visit_const_operand(constant, location);
294                    }
295                    Operand::RuntimeChecks(_) => {}
296                }
297            }
298
299            fn super_user_type_projection(&mut self, projection: &$($mutability)? UserTypeProjection) {
300                // This is a no-op on mir::Visitor.
301                let _ = projection;
302            }
303
304            fn super_ty(&mut self, ty: &$($mutability)? Ty) {
305                let _ = ty;
306            }
307
308            fn super_const_operand(&mut self, constant: &$($mutability)? ConstOperand, location: Location) {
309                let ConstOperand { span, user_ty: _, const_ } = constant;
310                self.visit_span(span);
311                self.visit_mir_const(const_, location);
312            }
313
314            fn super_mir_const(&mut self, constant: &$($mutability)? MirConst, location: Location) {
315                let MirConst { kind: _, ty, id: _ } = constant;
316                self.visit_ty(ty, location);
317            }
318
319            fn super_ty_const(&mut self, constant: &$($mutability)? TyConst) {
320                let _ = constant;
321            }
322
323            fn super_region(&mut self, region: &$($mutability)? Region) {
324                let _ = region;
325            }
326
327            fn super_args(&mut self, args: &$($mutability)? GenericArgs) {
328                let _ = args;
329            }
330
331            fn super_var_debug_info(&mut self, var_debug_info: &$($mutability)? VarDebugInfo) {
332                let VarDebugInfo { source_info, composite, value, name: _, argument_index: _ } =
333                    var_debug_info;
334                self.visit_span(&$($mutability)? source_info.span);
335                let location = Location(source_info.span);
336                if let Some(composite) = composite {
337                    self.visit_ty(&$($mutability)? composite.ty, location);
338                }
339                match value {
340                    VarDebugInfoContents::Place(place) => {
341                        self.visit_place(place, PlaceContext::NON_USE, location);
342                    }
343                    VarDebugInfoContents::Const(constant) => {
344                        self.visit_mir_const(&$($mutability)? constant.const_, location);
345                    }
346                }
347            }
348
349            fn super_assert_msg(&mut self, msg: &$($mutability)? AssertMessage, location: Location) {
350                match msg {
351                    AssertMessage::BoundsCheck { len, index } => {
352                        self.visit_operand(len, location);
353                        self.visit_operand(index, location);
354                    }
355                    AssertMessage::Overflow(_, left, right) => {
356                        self.visit_operand(left, location);
357                        self.visit_operand(right, location);
358                    }
359                    AssertMessage::OverflowNeg(op)
360                    | AssertMessage::DivisionByZero(op)
361                    | AssertMessage::RemainderByZero(op)
362                    | AssertMessage::InvalidEnumConstruction(op) => {
363                        self.visit_operand(op, location);
364                    }
365                    AssertMessage::ResumedAfterReturn(_)
366                    | AssertMessage::ResumedAfterPanic(_)
367                    | AssertMessage::NullPointerDereference
368                    | AssertMessage::ResumedAfterDrop(_) => {
369                        //nothing to visit
370                    }
371                    AssertMessage::MisalignedPointerDereference { required, found } => {
372                        self.visit_operand(required, location);
373                        self.visit_operand(found, location);
374                    }
375                }
376            }
377        }
378    };
379}
380
381macro_rules! super_body {
382    ($self:ident, $body:ident, mut) => {
383        for bb in $body.blocks.iter_mut() {
384            $self.visit_basic_block(bb);
385        }
386
387        $self.visit_ret_decl(RETURN_LOCAL, $body.ret_local_mut());
388
389        for (idx, arg) in $body.arg_locals_mut().iter_mut().enumerate() {
390            $self.visit_arg_decl(idx + 1, arg)
391        }
392
393        let local_start = $body.arg_count + 1;
394        for (idx, arg) in $body.inner_locals_mut().iter_mut().enumerate() {
395            $self.visit_local_decl(idx + local_start, arg)
396        }
397
398        for info in $body.var_debug_info.iter_mut() {
399            $self.visit_var_debug_info(info);
400        }
401
402        $self.visit_span(&mut $body.span)
403    };
404
405    ($self:ident, $body:ident, ) => {
406        let Body { blocks, locals: _, arg_count, var_debug_info, spread_arg: _, span } = $body;
407
408        for bb in blocks {
409            $self.visit_basic_block(bb);
410        }
411
412        $self.visit_ret_decl(RETURN_LOCAL, $body.ret_local());
413
414        for (idx, arg) in $body.arg_locals().iter().enumerate() {
415            $self.visit_arg_decl(idx + 1, arg)
416        }
417
418        let local_start = arg_count + 1;
419        for (idx, arg) in $body.inner_locals().iter().enumerate() {
420            $self.visit_local_decl(idx + local_start, arg)
421        }
422
423        for info in var_debug_info.iter() {
424            $self.visit_var_debug_info(info);
425        }
426
427        $self.visit_span(span)
428    };
429}
430
431macro_rules! visit_place_fns {
432    (mut) => {
433        fn super_place(&mut self, place: &mut Place, ptx: PlaceContext, location: Location) {
434            self.visit_local(&mut place.local, ptx, location);
435
436            for elem in place.projection.iter_mut() {
437                self.visit_projection_elem(elem, ptx, location);
438            }
439        }
440
441        // We don't have to replicate the `process_projection()` like we did in
442        // `rustc_middle::mir::visit.rs` here because the `projection` field in `Place`
443        // of Stable-MIR is not an immutable borrow, unlike in `Place` of MIR.
444        fn visit_projection_elem(
445            &mut self,
446            elem: &mut ProjectionElem,
447            ptx: PlaceContext,
448            location: Location,
449        ) {
450            self.super_projection_elem(elem, ptx, location)
451        }
452
453        fn super_projection_elem(
454            &mut self,
455            elem: &mut ProjectionElem,
456            ptx: PlaceContext,
457            location: Location,
458        ) {
459            match elem {
460                ProjectionElem::Deref => {}
461                ProjectionElem::Field(_idx, ty) => self.visit_ty(ty, location),
462                ProjectionElem::Index(local) => self.visit_local(local, ptx, location),
463                ProjectionElem::ConstantIndex { offset: _, min_length: _, from_end: _ } => {}
464                ProjectionElem::Subslice { from: _, to: _, from_end: _ } => {}
465                ProjectionElem::Downcast(_idx) => {}
466                ProjectionElem::OpaqueCast(ty) => self.visit_ty(ty, location),
467            }
468        }
469    };
470
471    () => {
472        fn super_place(&mut self, place: &Place, ptx: PlaceContext, location: Location) {
473            self.visit_local(&place.local, ptx, location);
474
475            for (idx, elem) in place.projection.iter().enumerate() {
476                let place_ref =
477                    PlaceRef { local: place.local, projection: &place.projection[..idx] };
478                self.visit_projection_elem(place_ref, elem, ptx, location);
479            }
480        }
481
482        fn visit_projection_elem<'a>(
483            &mut self,
484            place_ref: PlaceRef<'a>,
485            elem: &ProjectionElem,
486            ptx: PlaceContext,
487            location: Location,
488        ) {
489            let _ = place_ref;
490            self.super_projection_elem(elem, ptx, location);
491        }
492
493        fn super_projection_elem(
494            &mut self,
495            elem: &ProjectionElem,
496            ptx: PlaceContext,
497            location: Location,
498        ) {
499            match elem {
500                ProjectionElem::Deref => {}
501                ProjectionElem::Field(_idx, ty) => self.visit_ty(ty, location),
502                ProjectionElem::Index(local) => self.visit_local(local, ptx, location),
503                ProjectionElem::ConstantIndex { offset: _, min_length: _, from_end: _ } => {}
504                ProjectionElem::Subslice { from: _, to: _, from_end: _ } => {}
505                ProjectionElem::Downcast(_idx) => {}
506                ProjectionElem::OpaqueCast(ty) => self.visit_ty(ty, location),
507            }
508        }
509    };
510}
511
512pub trait MirVisitor {
    fn visit_body(&mut self, body: &Body) { self.super_body(body) }
    fn visit_basic_block(&mut self, bb: &BasicBlock) {
        self.super_basic_block(bb)
    }
    fn visit_ret_decl(&mut self, local: Local, decl: &LocalDecl) {
        self.super_ret_decl(local, decl)
    }
    fn visit_arg_decl(&mut self, local: Local, decl: &LocalDecl) {
        self.super_arg_decl(local, decl)
    }
    fn visit_local_decl(&mut self, local: Local, decl: &LocalDecl) {
        self.super_local_decl(local, decl)
    }
    fn visit_statement(&mut self, stmt: &Statement, location: Location) {
        self.super_statement(stmt, location)
    }
    fn visit_terminator(&mut self, term: &Terminator, location: Location) {
        self.super_terminator(term, location)
    }
    fn visit_span(&mut self, span: &Span) { self.super_span(span) }
    fn visit_place(&mut self, place: &Place, ptx: PlaceContext,
        location: Location) {
        self.super_place(place, ptx, location)
    }
    fn super_place(&mut self, place: &Place, ptx: PlaceContext,
        location: Location) {
        self.visit_local(&place.local, ptx, location);
        for (idx, elem) in place.projection.iter().enumerate() {
            let place_ref =
                PlaceRef {
                    local: place.local,
                    projection: &place.projection[..idx],
                };
            self.visit_projection_elem(place_ref, elem, ptx, location);
        }
    }
    fn visit_projection_elem<'a>(&mut self, place_ref: PlaceRef<'a>,
        elem: &ProjectionElem, ptx: PlaceContext, location: Location) {
        let _ = place_ref;
        self.super_projection_elem(elem, ptx, location);
    }
    fn super_projection_elem(&mut self, elem: &ProjectionElem,
        ptx: PlaceContext, location: Location) {
        match elem {
            ProjectionElem::Deref => {}
            ProjectionElem::Field(_idx, ty) => self.visit_ty(ty, location),
            ProjectionElem::Index(local) =>
                self.visit_local(local, ptx, location),
            ProjectionElem::ConstantIndex {
                offset: _, min_length: _, from_end: _ } => {}
            ProjectionElem::Subslice { from: _, to: _, from_end: _ } => {}
            ProjectionElem::Downcast(_idx) => {}
            ProjectionElem::OpaqueCast(ty) => self.visit_ty(ty, location),
        }
    }
    fn visit_local(&mut self, local: &Local, ptx: PlaceContext,
        location: Location) {
        let _ = (local, ptx, location);
    }
    fn visit_rvalue(&mut self, rvalue: &Rvalue, location: Location) {
        self.super_rvalue(rvalue, location)
    }
    fn visit_operand(&mut self, operand: &Operand, location: Location) {
        self.super_operand(operand, location)
    }
    fn visit_user_type_projection(&mut self,
        projection: &UserTypeProjection) {
        self.super_user_type_projection(projection)
    }
    fn visit_ty(&mut self, ty: &Ty, location: Location) {
        let _ = location;
        self.super_ty(ty)
    }
    fn visit_const_operand(&mut self, constant: &ConstOperand,
        location: Location) {
        self.super_const_operand(constant, location)
    }
    fn visit_mir_const(&mut self, constant: &MirConst, location: Location) {
        self.super_mir_const(constant, location)
    }
    fn visit_ty_const(&mut self, constant: &TyConst, location: Location) {
        let _ = location;
        self.super_ty_const(constant)
    }
    fn visit_region(&mut self, region: &Region, location: Location) {
        let _ = location;
        self.super_region(region)
    }
    fn visit_args(&mut self, args: &GenericArgs, location: Location) {
        let _ = location;
        self.super_args(args)
    }
    fn visit_assert_msg(&mut self, msg: &AssertMessage, location: Location) {
        self.super_assert_msg(msg, location)
    }
    fn visit_var_debug_info(&mut self, var_debug_info: &VarDebugInfo) {
        self.super_var_debug_info(var_debug_info);
    }
    fn super_body(&mut self, body: &Body) {
        let Body {
                blocks,
                locals: _,
                arg_count,
                var_debug_info,
                spread_arg: _,
                span } = body;
        for bb in blocks { self.visit_basic_block(bb); }
        self.visit_ret_decl(RETURN_LOCAL, body.ret_local());
        for (idx, arg) in body.arg_locals().iter().enumerate() {
            self.visit_arg_decl(idx + 1, arg)
        }
        let local_start = arg_count + 1;
        for (idx, arg) in body.inner_locals().iter().enumerate() {
            self.visit_local_decl(idx + local_start, arg)
        }
        for info in var_debug_info.iter() { self.visit_var_debug_info(info); }
        self.visit_span(span);
    }
    fn super_basic_block(&mut self, bb: &BasicBlock) {
        let BasicBlock { statements, terminator } = bb;
        for stmt in statements {
            self.visit_statement(stmt, Location(stmt.span));
        }
        self.visit_terminator(terminator, Location(terminator.span));
    }
    fn super_local_decl(&mut self, local: Local, decl: &LocalDecl) {
        let _ = local;
        let LocalDecl { ty, span, .. } = decl;
        self.visit_ty(ty, Location(*span));
    }
    fn super_ret_decl(&mut self, local: Local, decl: &LocalDecl) {
        self.super_local_decl(local, decl)
    }
    fn super_arg_decl(&mut self, local: Local, decl: &LocalDecl) {
        self.super_local_decl(local, decl)
    }
    fn super_statement(&mut self, stmt: &Statement, location: Location) {
        let Statement { kind, span } = stmt;
        self.visit_span(span);
        match kind {
            StatementKind::Assign(place, rvalue) => {
                self.visit_place(place, PlaceContext::MUTATING, location);
                self.visit_rvalue(rvalue, location);
            }
            StatementKind::FakeRead(_, place) |
                StatementKind::PlaceMention(place) => {
                self.visit_place(place, PlaceContext::NON_MUTATING, location);
            }
            StatementKind::SetDiscriminant { place, .. } |
                StatementKind::Retag(_, place) => {
                self.visit_place(place, PlaceContext::MUTATING, location);
            }
            StatementKind::StorageLive(local) |
                StatementKind::StorageDead(local) => {
                self.visit_local(local, PlaceContext::NON_USE, location);
            }
            StatementKind::AscribeUserType { place, projections, variance: _ }
                => {
                self.visit_place(place, PlaceContext::NON_USE, location);
                self.visit_user_type_projection(projections);
            }
            StatementKind::Coverage(coverage) => visit_opaque(coverage),
            StatementKind::Intrinsic(intrinsic) =>
                match intrinsic {
                    NonDivergingIntrinsic::Assume(operand) => {
                        self.visit_operand(operand, location);
                    }
                    NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
                        src, dst, count }) => {
                        self.visit_operand(src, location);
                        self.visit_operand(dst, location);
                        self.visit_operand(count, location);
                    }
                },
            StatementKind::ConstEvalCounter | StatementKind::Nop => {}
        }
    }
    fn super_terminator(&mut self, term: &Terminator, location: Location) {
        let Terminator { kind, span } = term;
        self.visit_span(span);
        match kind {
            TerminatorKind::Goto { .. } | TerminatorKind::Resume |
                TerminatorKind::Abort | TerminatorKind::Unreachable => {}
            TerminatorKind::Assert {
                cond, expected: _, msg, target: _, unwind: _ } => {
                self.visit_operand(cond, location);
                self.visit_assert_msg(msg, location);
            }
            TerminatorKind::Drop { place, target: _, unwind: _ } => {
                self.visit_place(place, PlaceContext::MUTATING, location);
            }
            TerminatorKind::Call {
                func, args, destination, target: _, unwind: _ } => {
                self.visit_operand(func, location);
                for arg in args { self.visit_operand(arg, location); }
                self.visit_place(destination, PlaceContext::MUTATING,
                    location);
            }
            TerminatorKind::InlineAsm { operands, .. } => {
                for op in operands {
                    let InlineAsmOperand { in_value, out_place, raw_rpr: _ } =
                        op;
                    if let Some(input) = in_value {
                        self.visit_operand(input, location);
                    }
                    if let Some(output) = out_place {
                        self.visit_place(output, PlaceContext::MUTATING, location);
                    }
                }
            }
            TerminatorKind::Return => {
                let local = RETURN_LOCAL;
                self.visit_local(&local, PlaceContext::NON_MUTATING,
                    location);
            }
            TerminatorKind::SwitchInt { discr, targets: _ } => {
                self.visit_operand(discr, location);
            }
        }
    }
    fn super_span(&mut self, span: &Span) { let _ = span; }
    fn super_rvalue(&mut self, rvalue: &Rvalue, location: Location) {
        match rvalue {
            Rvalue::AddressOf(mutability, place) => {
                let pcx =
                    PlaceContext { is_mut: *mutability == RawPtrKind::Mut };
                self.visit_place(place, pcx, location);
            }
            Rvalue::Aggregate(_, operands) => {
                for op in operands { self.visit_operand(op, location); }
            }
            Rvalue::BinaryOp(_, lhs, rhs) |
                Rvalue::CheckedBinaryOp(_, lhs, rhs) => {
                self.visit_operand(lhs, location);
                self.visit_operand(rhs, location);
            }
            Rvalue::Cast(_, op, ty) => {
                self.visit_operand(op, location);
                self.visit_ty(ty, location);
            }
            Rvalue::CopyForDeref(place) | Rvalue::Discriminant(place) |
                Rvalue::Len(place) => {
                self.visit_place(place, PlaceContext::NON_MUTATING, location);
            }
            Rvalue::Ref(region, kind, place) => {
                self.visit_region(region, location);
                let pcx =
                    PlaceContext {
                        is_mut: #[allow(non_exhaustive_omitted_patterns)] match kind
                            {
                            BorrowKind::Mut { .. } => true,
                            _ => false,
                        },
                    };
                self.visit_place(place, pcx, location);
            }
            Rvalue::Repeat(op, constant) => {
                self.visit_operand(op, location);
                self.visit_ty_const(constant, location);
            }
            Rvalue::ThreadLocalRef(_) => {}
            Rvalue::UnaryOp(_, op) | Rvalue::Use(op) => {
                self.visit_operand(op, location);
            }
        }
    }
    fn super_operand(&mut self, operand: &Operand, location: Location) {
        match operand {
            Operand::Copy(place) | Operand::Move(place) => {
                self.visit_place(place, PlaceContext::NON_MUTATING, location)
            }
            Operand::Constant(constant) => {
                self.visit_const_operand(constant, location);
            }
            Operand::RuntimeChecks(_) => {}
        }
    }
    fn super_user_type_projection(&mut self,
        projection: &UserTypeProjection) {
        let _ = projection;
    }
    fn super_ty(&mut self, ty: &Ty) { let _ = ty; }
    fn super_const_operand(&mut self, constant: &ConstOperand,
        location: Location) {
        let ConstOperand { span, user_ty: _, const_ } = constant;
        self.visit_span(span);
        self.visit_mir_const(const_, location);
    }
    fn super_mir_const(&mut self, constant: &MirConst, location: Location) {
        let MirConst { kind: _, ty, id: _ } = constant;
        self.visit_ty(ty, location);
    }
    fn super_ty_const(&mut self, constant: &TyConst) { let _ = constant; }
    fn super_region(&mut self, region: &Region) { let _ = region; }
    fn super_args(&mut self, args: &GenericArgs) { let _ = args; }
    fn super_var_debug_info(&mut self, var_debug_info: &VarDebugInfo) {
        let VarDebugInfo {
                source_info, composite, value, name: _, argument_index: _ } =
            var_debug_info;
        self.visit_span(&source_info.span);
        let location = Location(source_info.span);
        if let Some(composite) = composite {
            self.visit_ty(&composite.ty, location);
        }
        match value {
            VarDebugInfoContents::Place(place) => {
                self.visit_place(place, PlaceContext::NON_USE, location);
            }
            VarDebugInfoContents::Const(constant) => {
                self.visit_mir_const(&constant.const_, location);
            }
        }
    }
    fn super_assert_msg(&mut self, msg: &AssertMessage, location: Location) {
        match msg {
            AssertMessage::BoundsCheck { len, index } => {
                self.visit_operand(len, location);
                self.visit_operand(index, location);
            }
            AssertMessage::Overflow(_, left, right) => {
                self.visit_operand(left, location);
                self.visit_operand(right, location);
            }
            AssertMessage::OverflowNeg(op) | AssertMessage::DivisionByZero(op)
                | AssertMessage::RemainderByZero(op) |
                AssertMessage::InvalidEnumConstruction(op) => {
                self.visit_operand(op, location);
            }
            AssertMessage::ResumedAfterReturn(_) |
                AssertMessage::ResumedAfterPanic(_) |
                AssertMessage::NullPointerDereference |
                AssertMessage::ResumedAfterDrop(_) => {}
            AssertMessage::MisalignedPointerDereference { required, found } =>
                {
                self.visit_operand(required, location);
                self.visit_operand(found, location);
            }
        }
    }
}make_mir_visitor!(MirVisitor,);
513pub trait MutMirVisitor {
    fn visit_body(&mut self, body: &mut Body) { self.super_body(body) }
    fn visit_basic_block(&mut self, bb: &mut BasicBlock) {
        self.super_basic_block(bb)
    }
    fn visit_ret_decl(&mut self, local: Local, decl: &mut LocalDecl) {
        self.super_ret_decl(local, decl)
    }
    fn visit_arg_decl(&mut self, local: Local, decl: &mut LocalDecl) {
        self.super_arg_decl(local, decl)
    }
    fn visit_local_decl(&mut self, local: Local, decl: &mut LocalDecl) {
        self.super_local_decl(local, decl)
    }
    fn visit_statement(&mut self, stmt: &mut Statement, location: Location) {
        self.super_statement(stmt, location)
    }
    fn visit_terminator(&mut self, term: &mut Terminator,
        location: Location) {
        self.super_terminator(term, location)
    }
    fn visit_span(&mut self, span: &mut Span) { self.super_span(span) }
    fn visit_place(&mut self, place: &mut Place, ptx: PlaceContext,
        location: Location) {
        self.super_place(place, ptx, location)
    }
    fn super_place(&mut self, place: &mut Place, ptx: PlaceContext,
        location: Location) {
        self.visit_local(&mut place.local, ptx, location);
        for elem in place.projection.iter_mut() {
            self.visit_projection_elem(elem, ptx, location);
        }
    }
    fn visit_projection_elem(&mut self, elem: &mut ProjectionElem,
        ptx: PlaceContext, location: Location) {
        self.super_projection_elem(elem, ptx, location)
    }
    fn super_projection_elem(&mut self, elem: &mut ProjectionElem,
        ptx: PlaceContext, location: Location) {
        match elem {
            ProjectionElem::Deref => {}
            ProjectionElem::Field(_idx, ty) => self.visit_ty(ty, location),
            ProjectionElem::Index(local) =>
                self.visit_local(local, ptx, location),
            ProjectionElem::ConstantIndex {
                offset: _, min_length: _, from_end: _ } => {}
            ProjectionElem::Subslice { from: _, to: _, from_end: _ } => {}
            ProjectionElem::Downcast(_idx) => {}
            ProjectionElem::OpaqueCast(ty) => self.visit_ty(ty, location),
        }
    }
    fn visit_local(&mut self, local: &mut Local, ptx: PlaceContext,
        location: Location) {
        let _ = (local, ptx, location);
    }
    fn visit_rvalue(&mut self, rvalue: &mut Rvalue, location: Location) {
        self.super_rvalue(rvalue, location)
    }
    fn visit_operand(&mut self, operand: &mut Operand, location: Location) {
        self.super_operand(operand, location)
    }
    fn visit_user_type_projection(&mut self,
        projection: &mut UserTypeProjection) {
        self.super_user_type_projection(projection)
    }
    fn visit_ty(&mut self, ty: &mut Ty, location: Location) {
        let _ = location;
        self.super_ty(ty)
    }
    fn visit_const_operand(&mut self, constant: &mut ConstOperand,
        location: Location) {
        self.super_const_operand(constant, location)
    }
    fn visit_mir_const(&mut self, constant: &mut MirConst,
        location: Location) {
        self.super_mir_const(constant, location)
    }
    fn visit_ty_const(&mut self, constant: &mut TyConst, location: Location) {
        let _ = location;
        self.super_ty_const(constant)
    }
    fn visit_region(&mut self, region: &mut Region, location: Location) {
        let _ = location;
        self.super_region(region)
    }
    fn visit_args(&mut self, args: &mut GenericArgs, location: Location) {
        let _ = location;
        self.super_args(args)
    }
    fn visit_assert_msg(&mut self, msg: &mut AssertMessage,
        location: Location) {
        self.super_assert_msg(msg, location)
    }
    fn visit_var_debug_info(&mut self, var_debug_info: &mut VarDebugInfo) {
        self.super_var_debug_info(var_debug_info);
    }
    fn super_body(&mut self, body: &mut Body) {
        for bb in body.blocks.iter_mut() { self.visit_basic_block(bb); }
        self.visit_ret_decl(RETURN_LOCAL, body.ret_local_mut());
        for (idx, arg) in body.arg_locals_mut().iter_mut().enumerate() {
            self.visit_arg_decl(idx + 1, arg)
        }
        let local_start = body.arg_count + 1;
        for (idx, arg) in body.inner_locals_mut().iter_mut().enumerate() {
            self.visit_local_decl(idx + local_start, arg)
        }
        for info in body.var_debug_info.iter_mut() {
            self.visit_var_debug_info(info);
        }
        self.visit_span(&mut body.span);
    }
    fn super_basic_block(&mut self, bb: &mut BasicBlock) {
        let BasicBlock { statements, terminator } = bb;
        for stmt in statements {
            self.visit_statement(stmt, Location(stmt.span));
        }
        self.visit_terminator(terminator, Location(terminator.span));
    }
    fn super_local_decl(&mut self, local: Local, decl: &mut LocalDecl) {
        let _ = local;
        let LocalDecl { ty, span, .. } = decl;
        self.visit_ty(ty, Location(*span));
    }
    fn super_ret_decl(&mut self, local: Local, decl: &mut LocalDecl) {
        self.super_local_decl(local, decl)
    }
    fn super_arg_decl(&mut self, local: Local, decl: &mut LocalDecl) {
        self.super_local_decl(local, decl)
    }
    fn super_statement(&mut self, stmt: &mut Statement, location: Location) {
        let Statement { kind, span } = stmt;
        self.visit_span(span);
        match kind {
            StatementKind::Assign(place, rvalue) => {
                self.visit_place(place, PlaceContext::MUTATING, location);
                self.visit_rvalue(rvalue, location);
            }
            StatementKind::FakeRead(_, place) |
                StatementKind::PlaceMention(place) => {
                self.visit_place(place, PlaceContext::NON_MUTATING, location);
            }
            StatementKind::SetDiscriminant { place, .. } |
                StatementKind::Retag(_, place) => {
                self.visit_place(place, PlaceContext::MUTATING, location);
            }
            StatementKind::StorageLive(local) |
                StatementKind::StorageDead(local) => {
                self.visit_local(local, PlaceContext::NON_USE, location);
            }
            StatementKind::AscribeUserType { place, projections, variance: _ }
                => {
                self.visit_place(place, PlaceContext::NON_USE, location);
                self.visit_user_type_projection(projections);
            }
            StatementKind::Coverage(coverage) => visit_opaque(coverage),
            StatementKind::Intrinsic(intrinsic) =>
                match intrinsic {
                    NonDivergingIntrinsic::Assume(operand) => {
                        self.visit_operand(operand, location);
                    }
                    NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
                        src, dst, count }) => {
                        self.visit_operand(src, location);
                        self.visit_operand(dst, location);
                        self.visit_operand(count, location);
                    }
                },
            StatementKind::ConstEvalCounter | StatementKind::Nop => {}
        }
    }
    fn super_terminator(&mut self, term: &mut Terminator,
        location: Location) {
        let Terminator { kind, span } = term;
        self.visit_span(span);
        match kind {
            TerminatorKind::Goto { .. } | TerminatorKind::Resume |
                TerminatorKind::Abort | TerminatorKind::Unreachable => {}
            TerminatorKind::Assert {
                cond, expected: _, msg, target: _, unwind: _ } => {
                self.visit_operand(cond, location);
                self.visit_assert_msg(msg, location);
            }
            TerminatorKind::Drop { place, target: _, unwind: _ } => {
                self.visit_place(place, PlaceContext::MUTATING, location);
            }
            TerminatorKind::Call {
                func, args, destination, target: _, unwind: _ } => {
                self.visit_operand(func, location);
                for arg in args { self.visit_operand(arg, location); }
                self.visit_place(destination, PlaceContext::MUTATING,
                    location);
            }
            TerminatorKind::InlineAsm { operands, .. } => {
                for op in operands {
                    let InlineAsmOperand { in_value, out_place, raw_rpr: _ } =
                        op;
                    if let Some(input) = in_value {
                        self.visit_operand(input, location);
                    }
                    if let Some(output) = out_place {
                        self.visit_place(output, PlaceContext::MUTATING, location);
                    }
                }
            }
            TerminatorKind::Return => {
                let mut local = RETURN_LOCAL;
                self.visit_local(&mut local, PlaceContext::NON_MUTATING,
                    location);
            }
            TerminatorKind::SwitchInt { discr, targets: _ } => {
                self.visit_operand(discr, location);
            }
        }
    }
    fn super_span(&mut self, span: &mut Span) { let _ = span; }
    fn super_rvalue(&mut self, rvalue: &mut Rvalue, location: Location) {
        match rvalue {
            Rvalue::AddressOf(mutability, place) => {
                let pcx =
                    PlaceContext { is_mut: *mutability == RawPtrKind::Mut };
                self.visit_place(place, pcx, location);
            }
            Rvalue::Aggregate(_, operands) => {
                for op in operands { self.visit_operand(op, location); }
            }
            Rvalue::BinaryOp(_, lhs, rhs) |
                Rvalue::CheckedBinaryOp(_, lhs, rhs) => {
                self.visit_operand(lhs, location);
                self.visit_operand(rhs, location);
            }
            Rvalue::Cast(_, op, ty) => {
                self.visit_operand(op, location);
                self.visit_ty(ty, location);
            }
            Rvalue::CopyForDeref(place) | Rvalue::Discriminant(place) |
                Rvalue::Len(place) => {
                self.visit_place(place, PlaceContext::NON_MUTATING, location);
            }
            Rvalue::Ref(region, kind, place) => {
                self.visit_region(region, location);
                let pcx =
                    PlaceContext {
                        is_mut: #[allow(non_exhaustive_omitted_patterns)] match kind
                            {
                            BorrowKind::Mut { .. } => true,
                            _ => false,
                        },
                    };
                self.visit_place(place, pcx, location);
            }
            Rvalue::Repeat(op, constant) => {
                self.visit_operand(op, location);
                self.visit_ty_const(constant, location);
            }
            Rvalue::ThreadLocalRef(_) => {}
            Rvalue::UnaryOp(_, op) | Rvalue::Use(op) => {
                self.visit_operand(op, location);
            }
        }
    }
    fn super_operand(&mut self, operand: &mut Operand, location: Location) {
        match operand {
            Operand::Copy(place) | Operand::Move(place) => {
                self.visit_place(place, PlaceContext::NON_MUTATING, location)
            }
            Operand::Constant(constant) => {
                self.visit_const_operand(constant, location);
            }
            Operand::RuntimeChecks(_) => {}
        }
    }
    fn super_user_type_projection(&mut self,
        projection: &mut UserTypeProjection) {
        let _ = projection;
    }
    fn super_ty(&mut self, ty: &mut Ty) { let _ = ty; }
    fn super_const_operand(&mut self, constant: &mut ConstOperand,
        location: Location) {
        let ConstOperand { span, user_ty: _, const_ } = constant;
        self.visit_span(span);
        self.visit_mir_const(const_, location);
    }
    fn super_mir_const(&mut self, constant: &mut MirConst,
        location: Location) {
        let MirConst { kind: _, ty, id: _ } = constant;
        self.visit_ty(ty, location);
    }
    fn super_ty_const(&mut self, constant: &mut TyConst) { let _ = constant; }
    fn super_region(&mut self, region: &mut Region) { let _ = region; }
    fn super_args(&mut self, args: &mut GenericArgs) { let _ = args; }
    fn super_var_debug_info(&mut self, var_debug_info: &mut VarDebugInfo) {
        let VarDebugInfo {
                source_info, composite, value, name: _, argument_index: _ } =
            var_debug_info;
        self.visit_span(&mut source_info.span);
        let location = Location(source_info.span);
        if let Some(composite) = composite {
            self.visit_ty(&mut composite.ty, location);
        }
        match value {
            VarDebugInfoContents::Place(place) => {
                self.visit_place(place, PlaceContext::NON_USE, location);
            }
            VarDebugInfoContents::Const(constant) => {
                self.visit_mir_const(&mut constant.const_, location);
            }
        }
    }
    fn super_assert_msg(&mut self, msg: &mut AssertMessage,
        location: Location) {
        match msg {
            AssertMessage::BoundsCheck { len, index } => {
                self.visit_operand(len, location);
                self.visit_operand(index, location);
            }
            AssertMessage::Overflow(_, left, right) => {
                self.visit_operand(left, location);
                self.visit_operand(right, location);
            }
            AssertMessage::OverflowNeg(op) | AssertMessage::DivisionByZero(op)
                | AssertMessage::RemainderByZero(op) |
                AssertMessage::InvalidEnumConstruction(op) => {
                self.visit_operand(op, location);
            }
            AssertMessage::ResumedAfterReturn(_) |
                AssertMessage::ResumedAfterPanic(_) |
                AssertMessage::NullPointerDereference |
                AssertMessage::ResumedAfterDrop(_) => {}
            AssertMessage::MisalignedPointerDereference { required, found } =>
                {
                self.visit_operand(required, location);
                self.visit_operand(found, location);
            }
        }
    }
}make_mir_visitor!(MutMirVisitor, mut);
514
515/// This function is a no-op that gets used to ensure this visitor is kept up-to-date.
516///
517/// The idea is that whenever we replace an Opaque type by a real type, the compiler will fail
518/// when trying to invoke `visit_opaque`.
519///
520/// If you are here because your compilation is broken, replace the failing call to `visit_opaque()`
521/// by a `visit_<CONSTRUCT>` for your construct.
522fn visit_opaque(_: &Opaque) {}
523
524/// The location of a statement / terminator in the code and the CFG.
525#[derive(#[automatically_derived]
impl ::core::clone::Clone for Location {
    #[inline]
    fn clone(&self) -> Location {
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Location { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Location {
    #[inline]
    fn eq(&self, other: &Location) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Location {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Span>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for Location {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Location",
            &&self.0)
    }
}Debug)]
526pub struct Location(Span);
527
528impl Location {
529    pub fn span(&self) -> Span {
530        self.0
531    }
532}
533
534/// Location of the statement at the given index for a given basic block. Assumes that `stmt_idx`
535/// and `bb_idx` are valid for a given body.
536pub fn statement_location(body: &Body, bb_idx: &BasicBlockIdx, stmt_idx: usize) -> Location {
537    let bb = &body.blocks[*bb_idx];
538    let stmt = &bb.statements[stmt_idx];
539    Location(stmt.span)
540}
541
542/// Location of the terminator for a given basic block. Assumes that `bb_idx` is valid for a given
543/// body.
544pub fn terminator_location(body: &Body, bb_idx: &BasicBlockIdx) -> Location {
545    let bb = &body.blocks[*bb_idx];
546    let terminator = &bb.terminator;
547    Location(terminator.span)
548}
549
550/// Reference to a place used to represent a partial projection.
551pub struct PlaceRef<'a> {
552    pub local: Local,
553    pub projection: &'a [ProjectionElem],
554}
555
556impl PlaceRef<'_> {
557    /// Get the type of this place.
558    pub fn ty(&self, locals: &[LocalDecl]) -> Result<Ty, Error> {
559        self.projection.iter().try_fold(locals[self.local].ty, |place_ty, elem| elem.ty(place_ty))
560    }
561}
562
563/// Information about a place's usage.
564#[derive(#[automatically_derived]
impl ::core::marker::Copy for PlaceContext { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PlaceContext {
    #[inline]
    fn clone(&self) -> PlaceContext {
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for PlaceContext {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "PlaceContext",
            "is_mut", &&self.is_mut)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for PlaceContext {
    #[inline]
    fn eq(&self, other: &PlaceContext) -> bool { self.is_mut == other.is_mut }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for PlaceContext {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq, #[automatically_derived]
impl ::core::hash::Hash for PlaceContext {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.is_mut, state)
    }
}Hash)]
565pub struct PlaceContext {
566    /// Whether the access is mutable or not. Keep this private so we can increment the type in a
567    /// backward compatible manner.
568    is_mut: bool,
569}
570
571impl PlaceContext {
572    const MUTATING: Self = PlaceContext { is_mut: true };
573    const NON_MUTATING: Self = PlaceContext { is_mut: false };
574    const NON_USE: Self = PlaceContext { is_mut: false };
575
576    pub fn is_mutating(&self) -> bool {
577        self.is_mut
578    }
579}