Skip to content

Commit fc26e4e

Browse files
compiler: Document the offset invariant of OperandValue::Pair
1 parent df8102f commit fc26e4e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compiler/rustc_codegen_ssa/src/mir/operand.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ pub enum OperandValue<V> {
4545
Immediate(V),
4646
/// A pair of immediate LLVM values. Used by wide pointers too.
4747
///
48-
/// An `OperandValue` *must* be this variant for any type for which
48+
/// # Invariants
49+
/// - for `Pair(a, b)`, `a` is always offset 0 but **may** be `FieldIdx::ONE`
50+
/// - An `OperandValue` *must* be this variant for any type for which
4951
/// [`LayoutTypeCodegenMethods::is_backend_scalar_pair`] returns `true`.
50-
/// The backend values in this variant must be the *immediate* backend types,
52+
/// - The backend values in this variant must be the *immediate* backend types,
5153
/// as returned by [`LayoutTypeCodegenMethods::scalar_pair_element_backend_type`]
5254
/// with `immediate: true`.
5355
Pair(V, V),

0 commit comments

Comments
 (0)