Skip to main content

Rvalue

Enum Rvalue 

Source
pub enum Rvalue {
    Use(Operand),
    Borrow(BorrowKind, Place),
    BinaryOp(BinOp, Operand, Operand),
    UnaryOp(UnOp, Operand),
    Aggregate(Vec<Operand>),
    Clone(Operand),
    EnumTest {
        operand: Operand,
        variant: VariantTag,
    },
    EnumPayload {
        operand: Operand,
        variant: VariantTag,
    },
    TypePatternTest {
        operand: Operand,
        type_annotation: TypeAnnotation,
    },
    EnumDiscriminantTest {
        operand: Operand,
        enum_name: Option<String>,
        variant_name: String,
    },
}
Expand description

Right-hand side of an assignment.

Variants§

§

Use(Operand)

Use an operand directly.

§

Borrow(BorrowKind, Place)

Create a borrow: &place or &mut place

§

BinaryOp(BinOp, Operand, Operand)

Binary operation.

§

UnaryOp(UnOp, Operand)

Unary operation.

§

Aggregate(Vec<Operand>)

Function call result (arguments passed via terminator). This is a placeholder — actual calls use Call terminators.

§

Clone(Operand)

Clone of a value (explicit or auto-inferred).

§

EnumTest

Test whether a Result/Option scrutinee matches a specific variant (per ADR-006 §2.7.17 / Q18 — kinded Arc<ResultData> / Arc<OptionData> carrier). Result: native Bool (I8).

Emitted by lower_match_pattern_condition_operand when the scrutinee is a Pattern::Constructor with a recognised VariantTag::Ok / Err / Some_ / None_. JIT consumer dispatches to the jit_arc_result_is_ok / _is_err / jit_arc_option_is_some / _is_none FFI which reads is_ok / is_some from the *const ResultData / *const OptionData directly per §2.7.17 — no NaN-box tag decode, no is_heap_kind probe (§2.7.7 #4 / #7 forbidden).

Producer-side classification per W12-jit-result-option-trinity audit (docs/cluster-audits/w12-jit-match-enum-inline-audit.md §6.1).

Fields

§operand: Operand
§variant: VariantTag
§

EnumPayload

Extract the inner payload bits from a Result/Option scrutinee. Caller must have already proven the variant via EnumTest (control flow guarantees the matching arm is entered only when the variant matches; the variant tag here is the producer-side classification for kind sourcing, NOT a runtime check).

Result: raw u64 payload bits — the payload’s kind flows out of band via 6A’s Call-return-kind track + the EnumStore producer’s kind stamp.

JIT consumer dispatches to jit_arc_result_payload / jit_arc_option_payload which read the inner KindedSlot.raw() from the *const ResultData / *const OptionData and bump the inner refcount per the receiver-recovery soundness rule — the returned bits are an owned slot.

VariantTag::None_ is rejected at consumer time (no payload to extract — None’s payload field is a zero-bits Bool placeholder per ADR-006 §2.7.17 OptionData::none()).

Producer-side classification per W12-jit-result-option-trinity audit §6.2.

Fields

§operand: Operand
§variant: VariantTag
§

TypePatternTest

Test whether the scrutinee’s runtime kind matches a Pattern::Typed type annotation (e.g. match x { n: int => ..., s: string => ... }). Result: native Bool (I8).

W15.2-LANG-5 (Phase 4b, 2026-05-18). Pre-fix the MIR lowering of Pattern::Typed returned None for the condition operand — same shape as Pattern::Wildcard/Pattern::Identifier — so every typed match arm was reached via TerminatorKind::Goto with NO type discrimination. The first arm always won and the union-scrutinee silently took the wrong branch under JIT.

Producer-side classification per ADR-006 §2.7.5 stamp-at-compile-time: the type annotation is carried verbatim from ast::Pattern::Typed so consumers do not re-derive it from the operand bits.

Consumer status:

  • JIT MIR preflight (shape-jit::mir_compiler::preflight) REJECTS on this Rvalue → W12 fall-through routes the program to the bytecode interpreter, which compiles the same scrutinee via the OpCode::TypeCheck path in compiler/patterns/checking.rs. Native JIT codegen lands as a follow-up (jit_type_check FFI + per-kind dispatch on the §2.7.7 stack parallel-kind track).
  • VM never consumes MIR; compile_match_expr in compiler/expressions/advanced.rs calls compile_pattern_check directly on the AST and emits OpCode::TypeCheck itself.

The annotation IS the producer-side classification — neither a Bool-default fabrication nor any of the deleted dispatch families enumerated under CLAUDE.md Forbidden Patterns.

Fields

§operand: Operand
§type_annotation: TypeAnnotation
§

EnumDiscriminantTest

Test whether the scrutinee’s enum discriminant matches a specific user-defined Pattern::Constructor variant (e.g. match c { Color::Red => ..., Color::Green => ... }). Result: native Bool (I8).

W15.2-LANG-1 (Phase 4b, 2026-05-18). Pre-fix the MIR lowering of Pattern::Constructor for non-trinity (non-Ok/Err/Some/None) variants returned Some(Operand::Copy(Place::Local(scrutinee_slot))) — the raw Arc<TypedObjectStorage> pointer bits — as the SwitchBool condition. The JIT consumer’s generic I64-truthy check at terminators.rs::SwitchBool then evaluated the non-zero pointer as true for the first arm OR fell to false-branch when the multi-arm dispatch chain looped past the first arm, producing silent-empty-output for the user’s match Color::Red { Color::Red => print("red"), ... } case (book snippet enums.mdx:113).

Producer-side classification per ADR-006 §2.7.5 stamp-at-compile- time: the enum name + variant name are carried verbatim from ast::Pattern::Constructor so the consumer dispatches on a known (enum_name, variant_name) pair, NEVER on raw scrutinee bits.

Consumer status:

  • JIT MIR preflight (shape-jit::mir_compiler::preflight) REJECTS on this Rvalue → W12 fall-through routes the program to the bytecode interpreter, which compiles the same scrutinee via the compile_typed_enum_pattern_check path in compiler/patterns/checking.rs (emits GetFieldTyped(__variant, I64) + PushConst(expected_variant_id) + EqInt).
  • VM never consumes MIR; compile_match_expr in compiler/expressions/advanced.rs calls compile_pattern_check directly on the AST and emits the typed-object discriminant check itself.

The (enum_name, variant_name) pair IS the producer-side classification — neither a Bool-default fabrication nor any of the deleted dispatch families enumerated under CLAUDE.md Forbidden Patterns. Mirrors the LANG-5 TypePatternTest precedent (W15.2-LANG-5 close 2026-05-18) for Pattern::Typed.

Fields

§operand: Operand
§enum_name: Option<String>
§variant_name: String

Trait Implementations§

Source§

impl Clone for Rvalue

Source§

fn clone(&self) -> Rvalue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rvalue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Rvalue

Source§

fn eq(&self, other: &Rvalue) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Rvalue

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,