Skip to content

[bug] gen-rust: a slice next to a field called len, a slice-typed struct field and a [N]str constant generate Rust that does not compile #11182

Open

Description

@gHashTag

Goal

Fix three gen-rust defects the RFC experiment of #11177 found in the lowering of slices and strings, so generated Rust compiles for the forms the Rust back end is meant to carry: a slice parameter next to a struct field called len, a slice-typed struct field, and a [N]str constant.

Why

Found by lane R2 (RFC for #11177, section 6.1, defects D1 to D3), with t27c 0.5.2 built 2026-10-19 13:04. D1: when the module declares a struct field named len, gen-rust leaves t.len as written on a slice parameter instead of t.len(), and rustc fails with E0615; renamed count it compiles. D2: a slice-typed struct field is written as Vec<T> and the constructor takes it by value, so the caller's storage is moved and not borrowed (specs/tri/collections/stack.t27 becomes items: Vec<i64> and empty(storage: Vec<i64>); rustc reports 2 type errors). D3: a [N]str constant element is typed &str, which does not pass where []const u8 is expected (E0308). These sit in the same forms the out-buffer work (#9098, #11109) and every golden port (#11157) rely on.

Boundary

  • bootstrap/src/compiler.rs
  • specs/tri/collections/stack.t27
  • gen/rust/tri/collections/stack.rs

User Scenarios

  • Given a module with a struct field len and a function taking a slice, when gen-rust output is compiled with rustc, then it compiles and t.len() is called on the slice.
  • Given a struct with a slice-typed field, when gen-rust runs, then the field is a borrowed slice with a lifetime or the spec is refused with a reason, and the caller's storage is not moved.
  • Given a [N]str constant passed to a []const u8 parameter, when gen-rust runs, then the output compiles.

Requirements

  • FR-001: Each defect MUST have a failing probe (the spec, t27c gen-rust, rustc --crate-type lib) before the fix, kept as a test.
  • FR-002: The rules MUST live where the back end's rules live; hand Rust in bootstrap/ MUST NOT grow (own-language net <= 0).
  • FR-003: The committed gen/rust outputs MUST be regenerated where they change and the seals re-saved.

Success Criteria

  • The three probes compile with rustc and exit 0.
  • specs/tri/collections/stack.t27 generates Rust that compiles, with 0 type errors.

Activity

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions