Clarify more MIR docs

This commit is contained in:
Jakob Degen 2022-03-06 15:53:23 -05:00
parent fe40240e4d
commit 26d7b8ddb2

View File

@ -1561,6 +1561,8 @@ impl Statement<'_> {
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)]
pub enum StatementKind<'tcx> {
/// Write the RHS Rvalue to the LHS Place.
///
/// The LHS place may not overlap with any memory accessed on the RHS.
Assign(Box<(Place<'tcx>, Rvalue<'tcx>)>),
/// This represents all the reading that a pattern match may do
@ -1778,6 +1780,19 @@ static_assert_size!(Place<'_>, 16);
pub enum ProjectionElem<V, T> {
Deref,
Field(Field, T),
/// Index into a slice/array.
///
/// Note that this does not also dereference, and so it does not exactly correspond to slice
/// indexing in Rust. In other words, in the below Rust code:
///
/// ```rust
/// let x = &[1, 2, 3, 4];
/// let i = 2;
/// x[i];
/// ```
///
/// The `x[i]` is turned into a `Deref` followed by an `Index`, not just an `Index`. The same
/// thing is true of the `ConstantIndex` and `Subslice` projections below.
Index(V),
/// These indices are generated by slice patterns. Easiest to explain