Skip to content

Commit f0ddc7b

Browse files
committed
clarify semantics of ConstantIndex MIR projection
1 parent 5a4ee43 commit f0ddc7b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

compiler/rustc_middle/src/mir/syntax.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1135,8 +1135,10 @@ pub enum ProjectionElem<V, T> {
11351135
ConstantIndex {
11361136
/// index or -index (in Python terms), depending on from_end
11371137
offset: u64,
1138-
/// The thing being indexed must be at least this long. For arrays this
1139-
/// is always the exact length.
1138+
/// The thing being indexed must be at least this long -- otherwise, the
1139+
/// projection is UB.
1140+
///
1141+
/// For arrays this is always the exact length.
11401142
min_length: u64,
11411143
/// Counting backwards from end? This is always false when indexing an
11421144
/// array.

compiler/stable_mir/src/mir/body.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,10 @@ pub enum ProjectionElem {
768768
ConstantIndex {
769769
/// index or -index (in Python terms), depending on from_end
770770
offset: u64,
771-
/// The thing being indexed must be at least this long. For arrays this
772-
/// is always the exact length.
771+
/// The thing being indexed must be at least this long -- otherwise, the
772+
/// projection is UB.
773+
///
774+
/// For arrays this is always the exact length.
773775
min_length: u64,
774776
/// Counting backwards from end? This is always false when indexing an
775777
/// array.

0 commit comments

Comments
 (0)