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: StringCanonical/qualified name, as indexed (e.g. knot.stitch).
kind: SymbolKindDeclaration 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
: typeannotation on the VAR/CONST, resolved bycrate::annotations::resolvewith no downcast (soArray<int>,Map<string, int>, a declaredSTRUCTname,fn(T…): R,Handle<K>and (since issue #1552)Option<T>/Weighted<T>all survive — this is thety_to_inferred_typegap issue #1540 closes.rangestill has no annotation grammar at all (crate::annotations::resolvehas no arm for it — deferred pending demonstrated demand,docs/decision-log.md2026-07-27), so aTy::Rangevalue 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>forminfer_literal_typealready 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 fromtarget’s own declaration-derived signature (param_annotations/return_annotation— a second, single-levelsignature()call, never the target’s body). An unannotated target param/return reads asTy::Unknownin the row, the same conservative fallback declaration-derived typing always uses.
is_local: boolMarked 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§
impl Eq for Sig
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.