Skip to main content

Sig

Struct Sig 

Source
pub struct Sig {
    pub name: String,
    pub kind: SymbolKind,
    pub params: Vec<ParamInfo>,
    pub value_type: Option<InferredType>,
    pub value_ty: Option<Ty>,
    pub is_local: bool,
    pub param_annotations: Vec<Option<Ty>>,
    pub return_annotation: Option<Ty>,
}
Expand description

Per-declaration signature summary (phase-0 stub).

Everything here is declaration-derived: a body edit that doesn’t touch the declaration line(s) must not change a Sig.

Fields§

§name: String

Canonical/qualified name, as indexed (e.g. knot.stitch).

§kind: SymbolKind

Declaration kind.

§params: Vec<ParamInfo>

Declared parameters (knots, stitches, externals).

§value_type: Option<InferredType>

Type inferred from the initializer literal (VAR/CONST only), if the initializer is one. TM-2 (docs/typed-mode-spec.md §3): when the VAR/CONST also carries a : type annotation and that annotation resolves to a representable InferredType, the annotation replaces this value — annotation wins over inference (the firewall rule) — so every existing consumer of value_type (notably infer::collect_globals) picks up the annotated type automatically, with no seam change.

local_signature’s Param/Temp locals populate this field too (issue #530) — there it is never initializer-inferred (a local has no initializer-literal path here), only the downcast of the local’s own TM-2 : type annotation, None when unannotated or unresolved.

§value_ty: Option<Ty>

A VAR/CONST’s declaration-derived type at full Ty fidelity (issue #1540) — None for every other signature-produced symbol kind, and for a VAR/CONST whose declaration determines no type at all. local_signature (issue #530) is the one other producer that populates this field: for a Param/Temp, it is the local’s own TM-2 : type annotation resolved the same way, None when the local is unannotated — this is precisely the field brink-ide::hover::inferred_local_type_str reads via db.local_signature.

This is the field every typed consumer reads (collect_globals in both this crate and brink-db’s narrowed mirror); value_type above stays exactly as narrow as it was, because it is the wire-adjacent domain infer_value_meta/hover share and widening it would leak Array/Map/Struct/Fn/Option/Range into that schema.

Populated in TM-2 firewall order — annotation first, then the initializer:

  • an explicit : type annotation on the VAR/CONST, resolved by crate::annotations::resolve with no downcast (so Array<int>, Map<string, int>, a declared STRUCT name, fn(T…): R, Handle<K> and (since issue #1552) Option<T>/ Weighted<T> all survive — this is the ty_to_inferred_type gap issue #1540 closes. range still has no annotation grammar at all (crate::annotations::resolve has no arm for it — deferred pending demonstrated demand, docs/decision-log.md 2026-07-27), so a Ty::Range value can never actually reach this field yet;
  • else the initializer literal, at the same fidelity ([literal_ty]): #[…]Ty::Array, #{…}Ty::Map, Name#{…}Ty::Struct, plus every scalar/List<L> form infer_literal_type already covered;
  • else a fn-value initializer ([declared_fn_type]) — a bare #fn(target, args…) literal (T1c follow-up, issue #712, docs/t1c-spec.md §4), or, on the native surface only, a bare name resolving to a function definition (docs/t1c-spec.md §2a, issue #1895; zero bound args, since the binding form has no native spelling). Either way the type is the bound prefix consumed from target’s own declaration-derived signature (param_annotations/return_annotation — a second, single-level signature() call, never the target’s body). An unannotated target param/return reads as Ty::Unknown in the row, the same conservative fallback declaration-derived typing always uses.
§is_local: bool

Marked flow-private via a #@local directive (knots, stitches, VARs).

§param_annotations: Vec<Option<Ty>>

TM-2 (docs/typed-mode-spec.md §3): declared param type annotations, positional (parallel to params) — None per-slot for an unannotated param, or one whose annotation doesn’t resolve to a Ty (void, fn(...), an unrecognized name — crate::check_annotations reports those separately). Knots/stitches only; empty for other symbol kinds.

§return_annotation: Option<Ty>

TM-2: the function-header/stitch-header return type annotation (): type === on a knot, : type on a stitch — #1509 widened the grammar to stitches), resolved. None when absent, void, or unresolved. Knots and stitches only.

Trait Implementations§

Source§

impl Clone for Sig

Source§

fn clone(&self) -> Sig

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 Sig

Source§

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

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

impl Eq for Sig

Source§

impl PartialEq for Sig

Source§

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

Auto Trait Implementations§

§

impl Freeze for Sig

§

impl RefUnwindSafe for Sig

§

impl Send for Sig

§

impl Sync for Sig

§

impl Unpin for Sig

§

impl UnsafeUnpin for Sig

§

impl UnwindSafe for Sig

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

Source§

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

Compare self to key and return true if they are equal.
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> Lookup<T> for T

Source§

fn into_owned(self) -> T

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 = !

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

fn try_from(value: U) -> Result<T, !>

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> 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