Skip to main content

KwargPath

Enum KwargPath 

Source
pub enum KwargPath {
    Named(String),
    Item {
        key: String,
        idx: usize,
    },
    Slot(usize),
}
Expand description

Closed-set identifier for a kwargs-path projection — the form: label shape that a typed-entry kwarg failure renders into the compile error in {form}: prefix of a LispError::TypeMismatch diagnostic. Encodes the three reachable path shapes the kwargs gate emits — :<key> for a named kwarg (extract_string / extract_int / etc. failure), :<key>[<idx>] for the Nth item of a list-typed kwarg (extract_string_list per-item failure), and kwargs[<idx>] for an even-position slot that failed the “this-position-must-be-a-keyword” gate before a key was known (parse_kwargs direct call) — as a typed borrowed enum, so authoring tools (REPL, LSP, tatara-check) bind to path-shape identity (KwargPath::Item { .. } etc.) rather than substring-matching the rendered prefix.

Mirror at the kwargs-path-shape boundary of the prior-run MacroDefHead (macro-definition-head closed set), CompilerSpecIoStage (disk-persistence surface), TemplateInvariantKind (bytecode-runtime surface), and UnquoteForm (template-marker syntactic forms) closed-set lifts: those enums key their respective rejection variants on a typed identity carried inside the variant’s data shape; this enum keys the THREE distinct form: label shapes emitted by the kwarg-gate’s typed-entry chain on a typed path identity. The three format! literals that used to live inline in domain.rs::kwarg_form / kwarg_item_form / kwargs_pos_form (three byte-identical format! shapes, one per helper) collapse into ONE Display impl on this enum — the canonical literals (":<key>" / ":<key>[<idx>]" / "kwargs[<idx>]") live in ONE place, so a typo in any one of the three shapes can never drift independent of the others (THEORY.md §VI.1 three-times rule). Adding a fourth path shape (e.g., :<key>.<field> for nested-struct kwarg failures or :<key>::<variant> for sum-typed kwarg failures) requires extending this enum, which rustc-enforces matching at the Display projection site.

KwargPath owns its key payload as String so it can inhabit LispError::TypeMismatch.form (and any future error variant) without a borrow constraint. The owned shape is the typed-slot promotion the prior-run KwargPath landing pre-staged: every projection site that used to produce a String via KwargPath::Named(key).to_string() (the three sibling helpers kwarg_form / kwarg_item_form / kwargs_pos_form and the fourth kwarg_deserialize_form helper) now produces a typed KwargPath value directly; type_mismatch and every TypeMismatch.form consumer pattern-match on the variant identity (KwargPath::Item { key, idx }, KwargPath::Slot(idx), etc.) instead of substring-parsing the rendered prefix.

Copy is dropped because String is not Copy; Clone + Debug + PartialEq + Eq are retained (same posture as every other owned-data LispError field). The closed-set structural-completeness floor is unchanged — only the data ownership changed.

Theory anchor: THEORY.md §V.1 — knowable platform; the closed set of kwargs-path shapes becomes a TYPE rather than three byte-identical format! literals scattered across helper definitions. THEORY.md §VI.1 — generation over composition; the typed enum lands the structural-completeness floor for the kwargs-path surface, parallel to how CompilerSpecIoStage lands it for the disk-persistence surface, MacroDefHead for the macro-definition-head surface, TemplateInvariantKind for the bytecode-runtime surface, and UnquoteForm for the template-marker surface. THEORY.md §II.1 invariant 1 — typed entry; the kwargs-path’s renderable identity is part of the proof of WHICH kwarg-gate fired, and the typed enum makes that identity first-class — now as load-bearing data on the TypeMismatch variant rather than as a projection-to-String.

Variants§

§

Named(String)

:<key> — failure at a named kwarg (extract_string, extract_int, extract_float, extract_bool, etc.). The key is the offending kwarg’s identifier, owned so the variant lives independent of the call frame.

§

Item

:<key>[<idx>] — failure at the Nth item of a list-typed kwarg (extract_string_list per-item failure). The key is the containing kwarg’s identifier (owned); idx is the 0-based item index inside that kwarg’s list value.

Fields

§idx: usize
§

Slot(usize)

kwargs[<idx>] — failure at the Nth slot of the kwargs slice before a key was known (parse_kwargs’s “this-position-must-be-a-keyword” gate firing on an even-position slot). idx is the 0-based position into the raw kwargs slice (not into a particular kwarg’s value).

Implementations§

Source§

impl KwargPath

Source

pub fn named(key: &str) -> Self

Owned constructor for the :<key> shape — used by every call site that has a &str borrow of the kwarg identifier and wants to lift it into the typed enum without an inline .to_string() projection.

Source

pub fn item(key: &str, idx: usize) -> Self

Owned constructor for the :<key>[<idx>] shape — sibling of named, threading the per-item index alongside the kwarg key.

Source

pub const fn kind(&self) -> KwargPathKind

Discriminator projection — strips the payload and returns the closed-set KwargPathKind. The same shape every sibling payload-carrying closed-set enum in the workspace projects through (e.g. tatara_process::lifetime_clock::AutoTerminate::kindcrate::error::KwargPath’s tatara-process cousin AutoTerminateKind, TerminateReason::kindTerminateReasonKind, crate::matrix::SelectStrategy::kindSelectStrategyKind).

Consumers that group LispError::TypeMismatch / LispError::KwargDeserialize failures by path-shape CATEGORY rather than full path identity (failure-cluster metrics labelled path_kind=named / path_kind=item / path_kind=slot, an LSP that surfaces “this is a per-item failure” before drilling into the bracket-suffix, a future tatara-check diagnostic histogram that buckets by kind) project through this method instead of destructuring the variant and discarding the payload at every site. Adding a fourth path shape (e.g., :<key>.<field> for nested-struct kwarg failures or :<key>::<variant> for sum-typed kwarg failures) requires extending KwargPathKind, which rustc-enforces matching at this projection.

Trait Implementations§

Source§

impl Clone for KwargPath

Source§

fn clone(&self) -> KwargPath

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 KwargPath

Source§

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

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

impl Display for KwargPath

Source§

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

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

impl Eq for KwargPath

Source§

impl PartialEq for KwargPath

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for KwargPath

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, 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.