clarify semantics of ConstantIndex MIR projection

This commit is contained in:
Ralf Jung 2024-10-05 12:19:14 +02:00
parent 5a4ee43c38
commit f0ddc7b472
2 changed files with 8 additions and 4 deletions

View File

@ -1135,8 +1135,10 @@ pub enum ProjectionElem<V, T> {
ConstantIndex {
/// index or -index (in Python terms), depending on from_end
offset: u64,
/// The thing being indexed must be at least this long. For arrays this
/// is always the exact length.
/// The thing being indexed must be at least this long -- otherwise, the
/// projection is UB.
///
/// For arrays this is always the exact length.
min_length: u64,
/// Counting backwards from end? This is always false when indexing an
/// array.

View File

@ -768,8 +768,10 @@ pub enum ProjectionElem {
ConstantIndex {
/// index or -index (in Python terms), depending on from_end
offset: u64,
/// The thing being indexed must be at least this long. For arrays this
/// is always the exact length.
/// The thing being indexed must be at least this long -- otherwise, the
/// projection is UB.
///
/// For arrays this is always the exact length.
min_length: u64,
/// Counting backwards from end? This is always false when indexing an
/// array.