about summary refs log tree commit diff
path: root/compiler/rustc_middle
diff options
context:
space:
mode:
authorJakob Degen <jakob.e.degen@gmail.com>2022-03-06 15:53:23 -0500
committerJakob Degen <jakob.e.degen@gmail.com>2022-03-23 18:34:08 -0400
commit26d7b8ddb2d323e2d6cb77c04caf7c58ce5af267 (patch)
treea1fefc101d66788a641d8ea63e3d89a236a0a967 /compiler/rustc_middle
parentfe40240e4d4154c349e9c76514badbfed7a0a0cf (diff)
downloadrust-26d7b8ddb2d323e2d6cb77c04caf7c58ce5af267.tar.gz
rust-26d7b8ddb2d323e2d6cb77c04caf7c58ce5af267.zip
Clarify more MIR docs
Diffstat (limited to 'compiler/rustc_middle')
-rw-r--r--compiler/rustc_middle/src/mir/mod.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs
index 59cd7d7dda7..ea71cff1616 100644
--- a/compiler/rustc_middle/src/mir/mod.rs
+++ b/compiler/rustc_middle/src/mir/mod.rs
@@ -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