Skip to content

t27o: a fn returning Vec<T> built by push converts in the out-buffer form (step 2 of #10546) #11073

Closed

Description

@gHashTag

Goal

Step 2 of #10546 (part of #10522): a Rust fn that returns Vec<T> and builds the result only by push / extend_from_slice converts in the out-buffer form, the move #9098 made for an owned String. The fn takes a last out: []T parameter and returns usize, the number of elements the Rust fn would have returned; the oracle checks the written prefix. A returned Vec that the fn also reads or changes in another way, a second Vec, or any other way of building the result stays refused, with a reason that says which.

Why this matters

The step-1 dogfood (#10648, five repositories at t27 7496ed2, trios 483dd9ee, trinity 0770abb9, trinity-fpga 20bf4c418, 999-multibots-telegraf 6e5512881) left type Vec the first refusal of 1,126 fns. 534 of them return a bare Vec<T>. Only a part of those build the result as a list that grows by push; the rest return a vec![..] literal, a collect(), a clone or a delegated call. The measure is in the PR, before and after, so the share of the 16 % that this form can reach is a number and not a guess.

Source of truth

specs/tools/t27o/rust_convert.t27: the subset header (the out-buffer form for an owned String, #9098), string_out_form and out_str_stmt as the model, vectors for the oracle; rust_std.t27 is not needed (a push is out[w] = e; w = w + 1).

Boundary

  • specs/tools/t27o/rust_convert.t27
  • gen/rust/tools/t27o/rust_convert.rs
  • .trinity/seals/t27o_T27oRust.json
  • Must not touch: cli/tri/src/main.rs, spice_convert.t27, rust_std.t27, any ledger or docs/reports/t27b_expectations.json.

User Scenarios

  • Given fn bits(x: u8) -> Vec<bool> { let mut v = Vec::new(); for i in 0..8 { v.push((x >> i) & 1 == 1); } v }, When tri t27o converts it, Then the spec has fn bits(x: u8, out: []bool) -> usize, which writes out[w] = e while w < out.len, counts w on past the end, and returns it, and the oracle asserts the count and every written element against what Rust returned, once with a 256-element buffer and once with a zero-length one.
  • Given a fn that also reads its Vec (v.len(), v[0]), resizes it (insert, pop, sort), assigns into it, hands it on (&v, &mut v) or keeps a second Vec, When it is converted, Then it is refused with a reason that names the use, and never converted with a capacity the source does not state.
  • Given a fn that calls a fn converted in the out-buffer form, When it is converted, Then it is refused with a reason that names the call, because the caller would have to own an unbounded buffer.

Requirements

  • FR-001: The converter MUST lower a fn whose result is Vec<T> (T an integer, float or bool type) into the out-buffer form when the result is one local made by Vec::new(), Vec::with_capacity(n) or vec![], changed only by push(e) and extend_from_slice(s), and returned (return v, the tail v, or an empty Vec::new() / vec![]).
  • FR-002: The out-buffer form MUST NOT approximate a capacity: the capacity is the caller's, an element past out.len is counted and not written, and the result is the number of elements the Rust fn returns.
  • FR-003: The oracle MUST record the written prefix: the count, and every element of a result of at most 256 elements, once with a 256-element buffer and once with a zero-length buffer.
  • FR-004: A returned Vec that the fn reads or changes beyond push / extend_from_slice, that is not the one local, or a second Vec local MUST be refused with a reason that names the use; a call of an out-buffer fn MUST be refused with a reason that names the call.
  • FR-005: The change MUST add no hand-written Rust: the rule is the spec and gen/rust/tools/t27o/rust_convert.rs is regenerated; the converter's tests MUST pass under t27b test with 0 vacuous passes under t27c test-report and coverage of every fn by a test at 100 %.
  • FR-006: The PR MUST report, on the same five repositories and commits, the count of fns that return Vec<T>, how many convert, and the first-refusal counts of type Vec before and after, and no converted output may change except where a Vec result was involved.

Success Criteria

  • t27b test specs/tools/t27o/rust_convert.t27 passes, and t27c test-report on it reports vacuous passes 0
  • t27c coverage specs/tools/t27o/rust_convert.t27 reports every fn covered (100 %)
  • 0 files go from a passing --check to a failing one on the replayed files
  • 0 net hand-written Rust lines added (the own-language gate prints nothing and exits 0)

Activity

  1. added 8 commits that reference this issue on Oct 19, 2026
    26f8c60
    1e6f335
    46b3eff
    4759b63
    d26c6d6
    abe5f28
    98910f2
    0bc68a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions