Skip to content

Commit 26d7b8d

Browse files
committed
Clarify more MIR docs
1 parent fe40240 commit 26d7b8d

File tree

1 file changed

+15
-0
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+15
-0
lines changed

compiler/rustc_middle/src/mir/mod.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,8 @@ impl Statement<'_> {
15611561
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable)]
15621562
pub enum StatementKind<'tcx> {
15631563
/// Write the RHS Rvalue to the LHS Place.
1564+
///
1565+
/// The LHS place may not overlap with any memory accessed on the RHS.
15641566
Assign(Box<(Place<'tcx>, Rvalue<'tcx>)>),
15651567

15661568
/// This represents all the reading that a pattern match may do
@@ -1778,6 +1780,19 @@ static_assert_size!(Place<'_>, 16);
17781780
pub enum ProjectionElem<V, T> {
17791781
Deref,
17801782
Field(Field, T),
1783+
/// Index into a slice/array.
1784+
///
1785+
/// Note that this does not also dereference, and so it does not exactly correspond to slice
1786+
/// indexing in Rust. In other words, in the below Rust code:
1787+
///
1788+
/// ```rust
1789+
/// let x = &[1, 2, 3, 4];
1790+
/// let i = 2;
1791+
/// x[i];
1792+
/// ```
1793+
///
1794+
/// The `x[i]` is turned into a `Deref` followed by an `Index`, not just an `Index`. The same
1795+
/// thing is true of the `ConstantIndex` and `Subslice` projections below.
17811796
Index(V),
17821797

17831798
/// These indices are generated by slice patterns. Easiest to explain

0 commit comments

Comments
 (0)