Skip to main content

NativeKind

Enum NativeKind 

Source
pub enum NativeKind {
Show 30 variants Float64, NullableFloat64, Float32, Char, Int8, NullableInt8, UInt8, NullableUInt8, Int16, NullableInt16, UInt16, NullableUInt16, Int32, NullableInt32, UInt32, NullableUInt32, Int64, NullableInt64, UInt64, NullableUInt64, IntSize, NullableIntSize, UIntSize, NullableUIntSize, Bool, Null, String, StringV2, DecimalV2, Ptr(HeapKind),
}
Expand description

Storage discriminator for a single 8-byte typed slot.

Each variant identifies which native type the slot’s u64 raw bits represent, including width and nullability for integers and float. Boolean has no width variant. String is special-cased as the most common heap shape (an Arc<String> raw pointer); all other heap- allocated shapes use Ptr(HeapKind) carrying the surviving HeapValue discriminant. The kind tells the marshal/wire/snapshot layer which HeapValue arm the bits decode to without probing the bits themselves.

Variants§

§

Float64

Plain f64 value (direct float operations)

§

NullableFloat64

Nullable f64 using NaN sentinel (Option) IEEE 754: NaN + x = NaN, so null propagates automatically

§

Float32

Plain f32 value (4-byte single-precision float). ADR-006 §2.7.5 amendment (Round 19 S1.5 W12-nativekind-scalar-additions, 2026-05-14): non-parametric scalar variant introduced for Array<f32> v2-raw producer paths. f32 is Copy + 4-byte and fits the v2-raw TypedArray<T> flat-struct shape without Arc wrapping. Slot bits store the f32 zero-extended into the low 32 bits of the 8-byte slot via f32::to_bits (zero-extended).

§

Char

Plain char value (4-byte Unicode scalar). ADR-006 §2.7.5 amendment (Round 19 S1.5 W12-nativekind-scalar-additions, 2026-05-14): non-parametric scalar variant introduced for Array<char> v2-raw producer paths. char is Copy + 4-byte (UTF-32 scalar-value subset of u32) and fits the v2-raw TypedArray<T> flat-struct shape without Arc wrapping. Slot bits store the codepoint as c as u32 zero-extended into the low 32 bits of the 8-byte slot.

Parallel-discriminator note (CLAUDE.md §Parallel-implementation across producer/consumer carrier-shape boundaries): the existing NativeKind::Ptr(HeapKind::Char) carrier remains in source for inline-char-value paths that push char values directly to the VM stack without going through the §2.7.6/Q8 KindedSlot::from_char constructor. NativeKind::Char is the scalar-bucket carrier (the canonical §2.7.6/Q8 constructor target); NativeKind::Ptr(HeapKind::Char) is a per-element carrier label for the inline-codepoint payload pattern. Both labels are read-side-equivalent (slot bits in both shapes are c as u32 zero-extended), but consumer dispatch sites MUST handle either label exhaustively for correctness — the NativeKind::Char arm is the §Q8 carrier-API target, the Ptr(HeapKind::Char) arm is the pre-amendment inline-payload pattern. A future sub-cluster (cluster-1 hardening) folds the Ptr(HeapKind::Char) arms into NativeKind::Char exhaustively once the HeapKind::Char label can be retired.

§

Int8

Plain i8 value

§

NullableInt8

Nullable i8 value

§

UInt8

Plain u8 value

§

NullableUInt8

Nullable u8 value

§

Int16

Plain i16 value

§

NullableInt16

Nullable i16 value

§

UInt16

Plain u16 value

§

NullableUInt16

Nullable u16 value

§

Int32

Plain i32 value

§

NullableInt32

Nullable i32 value

§

UInt32

Plain u32 value

§

NullableUInt32

Nullable u32 value

§

Int64

Plain i64 value

§

NullableInt64

Nullable i64 value

§

UInt64

Plain u64 value

§

NullableUInt64

Nullable u64 value

§

IntSize

Plain isize value

§

NullableIntSize

Nullable isize value

§

UIntSize

Plain usize value

§

NullableUIntSize

Nullable usize value

§

Bool

Boolean value. Slot bits: 0 = false, 1 = true. Bool slots NEVER carry the null/unit sentinel — null is a distinct variant (NativeKind::Null) per the R5b-2-bool-null-sentinel disposition (ADR-006 §2.7 carrier-semantics + §2.7.7/Q9 parallel-kind track, 2026-05-19): pre-disposition (0u64, NativeKind::Bool) was the canonical null sentinel, which collided with legitimate false bool values (both encoded as bits=0). The collision caused VM-only divergence per W14.2-G6 SURFACE-G6-BOOL-NULL + SURFACE-G6-LET-ONLY-BODY + SURFACE-G6-NONE-OUTPUT-ADAPTER. Post-disposition: Bool slots carry only {0, 1} bits; null is pushed with NativeKind::Null discriminator (kind from the §2.7.7/Q9 parallel-kind track), restoring the kind-discriminator soundness invariant.

§

Null

Unit / null sentinel. Non-parametric scalar variant indicating the slot carries the absence-of-value marker (None / null / implicit unit return). R5b-2-bool-null-sentinel-cluster (ADR-006 §2.7 carrier semantics + §2.7.5 producer-side stamp + §2.7.7/Q9 parallel-kind track, 2026-05-19): introduced to fix the §2.7 (0u64, NativeKind::Bool) null-sentinel ⇔ false bool bit-pattern collision surfaced by W14.2-G6.

Slot bits are unspecified and ignored — the kind alone carries the absence signal. Producers use 0u64 by convention so uninitialized stack-pad bytes (already zero per push_kinded_slow) project to the same wire shape under NativeKind::Null if accidentally observed (defense in depth).

Clone/drop: no-op (no Arc<T> payload, no refcount work) — mirrors the inline-scalar arm of clone_with_kind / drop_with_kind per ADR-006 §2.7.7/Q9 + §2.7.6/Q8 dispatch tables.

Wire projection: WireValue::Null (mirrors the NullableFloat64 NaN-sentinel arm at slot_to_wire).

is_null_kinded: returns true for any (_, NativeKind::Null) pair regardless of bits — kind IS the discriminator per §2.7.7/Q9 (not “kind PLUS bit pattern of data slot”, which was the pre-disposition shape that the §2.7 collision exposed as unsound).

§

String

String reference (Arc raw pointer)

§

StringV2

v2-raw *const StringObj carrier reference. ADR-006 §2.7.5 amendment (Wave 2 Agent B W12-StringV2-DecimalV2-NativeKind-additions, 2026-05-14): new heap-pointer variant introduced for v2-raw Array<string> element read paths per TypedArray<*const StringObj> (Wave 2 §A2 producer migration). Slot bits store ptr as u64 where ptr: *const StringObj — retain/release uses v2_retain / v2_release against the HeapHeader at offset 0 of StringObj (NOT Arc::increment_strong_countStringObj is a manually-allocated repr(C) carrier with its own refcount discipline per v2/refcount.rs, not an Arc<String>).

Parallel-discriminator note (CLAUDE.md §Parallel-implementation across producer/consumer carrier-shape boundaries): this variant is a per-carrier-shape discriminator distinct from NativeKind::String (Arc<String> carrier); the two are structurally distinct (StringObj is a repr(C) 24-byte HeapHeader-equipped struct, Arc<String> is a Rust-managed Arc<T> allocation). Mixing the two carriers under the same NativeKind discriminator is the H-b defection refused per the audit §H.2; the H-c decision (option adopted at §H.4 + supervisor §P.1 ratification 2026-05-14) gives each carrier its own NativeKind variant explicitly.

§

DecimalV2

v2-raw *const DecimalObj carrier reference. ADR-006 §2.7.5 amendment (Wave 2 Agent B W12-StringV2-DecimalV2-NativeKind-additions, 2026-05-14): new heap-pointer variant introduced for v2-raw Array<decimal> element read paths per TypedArray<*const DecimalObj> (Wave 2 §A2 producer migration). Slot bits store ptr as u64 where ptr: *const DecimalObj — retain/release uses v2_retain / v2_release against the HeapHeader at offset 0 of DecimalObj (NOT Arc::increment_strong_count against an Arc<rust_decimal::Decimal>DecimalObj is a manually-allocated repr(C) carrier per v2/decimal_obj.rs + v2/refcount.rs).

Parallel-discriminator note (CLAUDE.md §Parallel-implementation across producer/consumer carrier-shape boundaries): this variant is a per-carrier-shape discriminator distinct from NativeKind::Ptr(HeapKind::Decimal) (Arc<rust_decimal::Decimal> carrier); the two are structurally distinct (DecimalObj is a repr(C) 24-byte HeapHeader-equipped struct, Arc<Decimal> is a Rust-managed Arc<T> allocation). Same H-c decision rationale as StringV2.

§

Ptr(HeapKind)

Heap pointer (Arc<HeapValue> raw pointer) whose HeapValue discriminant is kind. The marshal/wire/snapshot layer dispatches on kind to project the slot to its typed shape — it does not probe the heap object’s self-reported discriminant in production ((*hv).kind() == kind is a debug-only sanity check).

Watchlist (docs/defections.md 2026-05-06 — HeapKind trim + Ptr extension): do NOT add parametric NativeKind::Result(..), NativeKind::Option(..), or NativeKind::JsonValue variants when stdlib mass migration hits those returns. The strict-typed answer is HeapKind::TypedObject plus a per-instantiation schema_id from the function’s registered ConcreteType. Adding parametric NativeKind variants re-creates heterogeneous-by-default sum types at the discriminator level — the same defection pattern as the rejected enum SlotValue { Int, Float, Bool, Heap }.

Implementations§

Source§

impl NativeKind

Source

pub fn is_integer(self) -> bool

Source

pub fn is_nullable_integer(self) -> bool

Source

pub fn is_integer_family(self) -> bool

Source

pub fn is_default_int_family(self) -> bool

Source

pub fn is_float_family(self) -> bool

Source

pub fn is_char_scalar(self) -> bool

Whether this is the Char scalar (per ADR-006 §2.7.5 amendment, Round 19 S1.5). Note: this does NOT include the pre-amendment NativeKind::Ptr(HeapKind::Char) carrier label — callers that want to recognize both shapes must check is_char_family() instead. The scalar-only predicate exists because Char is a non-heap scalar at the §Q8 carrier-API layer (no Arc<T> payload, refcount-equivalent to other 4-byte scalars).

Source

pub fn is_numeric_family(self) -> bool

Source

pub fn is_pointer_sized_integer(self) -> bool

Source

pub fn is_signed_integer(self) -> Option<bool>

Source

pub fn integer_bit_width(self) -> Option<u16>

Source

pub fn is_refcounted(self) -> bool

Whether values of this kind carry a refcounted heap pointer.

Post-strict-typing (ADR-006 §2.7.5 / §2.7.6 / Q8), the kind IS the discriminator that decides refcount semantics — there is no tag-bit probing. Heap kinds are String (Arc raw pointer) and Ptr(HeapKind::*) (Arc raw pointer). All numeric / bool kinds — including their nullable variants — are raw scalars and do NOT carry a refcount, regardless of Cranelift storage width (an Int64 slot is a raw i64, not a NaN-boxed ValueWord; the deleted ValueWord ABI is what made the W-series is_native_slot predicate exclude Int64).

Used by shape-jit/src/mir_compiler/ownership.rs to gate jit_arc_retain / jit_arc_release emission. The kind-blind fall-through (“if kind isn’t proven, assume heap and retain”) the prior W-series MIR emitter took is forbidden under §2.7.7 #9 — when kind isn’t proven, surface-and-stop is the principled response, not a Bool-default-like silent retain.

Source

pub fn non_nullable(self) -> Self

Source

pub fn with_nullability(self, nullable: bool) -> Self

Source

pub fn combine_integer_hints(lhs: Self, rhs: Self) -> Option<Self>

Trait Implementations§

Source§

impl Clone for NativeKind

Source§

fn clone(&self) -> NativeKind

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 NativeKind

Source§

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

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

impl<'de> Deserialize<'de> for NativeKind

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for NativeKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for NativeKind

Source§

fn eq(&self, other: &NativeKind) -> 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 Serialize for NativeKind

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for NativeKind

Source§

impl Eq for NativeKind

Source§

impl StructuralPartialEq for NativeKind

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,