diff options
| author | Ralf Jung <post@ralfj.de> | 2024-10-05 12:19:14 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-10-05 12:19:14 +0200 |
| commit | f0ddc7b472a6ea84f2224364e2b71c688b7b285e (patch) | |
| tree | 1a14bd8a4bebb0bc9526ab6284a580c9a4403c4d | |
| parent | 5a4ee43c387110736440cecc375cb5aedc441dbc (diff) | |
| download | rust-f0ddc7b472a6ea84f2224364e2b71c688b7b285e.tar.gz rust-f0ddc7b472a6ea84f2224364e2b71c688b7b285e.zip | |
clarify semantics of ConstantIndex MIR projection
| -rw-r--r-- | compiler/rustc_middle/src/mir/syntax.rs | 6 | ||||
| -rw-r--r-- | compiler/stable_mir/src/mir/body.rs | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index ae75f2d4187..1722a7a1f35 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -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. diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 9f4db7e4833..742469a1c93 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -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. |
