Skip to content

Commit 406ac2e

Browse files
Give usage instructions IndirectlyMutableLocals docs
1 parent bc7928a commit 406ac2e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/librustc_mir/dataflow/impls/indirect_mutation.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ use crate::dataflow::{self, GenKillSet};
1010
/// indirectly. This could either be a mutable reference (`&mut`) or a shared borrow if the type of
1111
/// that `Local` allows interior mutability.
1212
///
13-
/// If this returns `false` for a `Local` at a given `Location`, the user can assume that `Local`
14-
/// has not been mutated as a result of an indirect assignment (`*p = x`) or as a side-effect of a
15-
/// function call or drop terminator.
13+
/// If this returns false for a `Local` at the location of an indirect assignment, that `Local`
14+
/// cannot be mutated by that assignment. For example, if the dataflow state at a statement like
15+
/// `*p = 42` contained locals `x` and `z` but not `y`, we know that while `x` or `z` may be the
16+
/// target of that assignment, `y` cannot be.
17+
///
18+
/// Assignments through a pointer are not the only place where a `Local` can be mutated indirectly:
19+
/// Function calls, drop terminators and inline assembly can all mutate `Local`s as a side-effect.
1620
#[derive(Copy, Clone)]
1721
pub struct IndirectlyMutableLocals<'mir, 'tcx> {
1822
body: &'mir mir::Body<'tcx>,

0 commit comments

Comments
 (0)