Skip to content

gen-rust: a local array passed to a mutable slice parameter lowers to &mut &(w), which rustc refuses #10785

Open

Description

@gHashTag

Goal

t27c gen-rust must lower a call that passes a local array to a mutable slice parameter as &mut w, not &mut &(w). Today rustc refuses the generated code, so any spec reached from tri through gen-rust cannot call such a function, and a caller has to copy the function instead of using it (see #10766 / PR #10781, where spice_convert.t27 re-states linear.t27's MNA stamp as pair_add / src_add for this reason).

Repro (t27c 0.5.2 at master 2ee0cb6)

specs/analog/linear.t27 line 397 declares pub fn stamp_pair(w: []f64, off: usize, a: u8, b: u8, y: f64), and stamp (line 414) calls it on a local var w : [55]f64 as stamp_pair(&w, 0, a[e], b[e], 1.0 / val[e]);.

t27c gen-rust specs/analog/linear.t27 emits:

pub fn stamp_pair(w: &mut [f64], off: usize, a: u8, b: u8, y: f64) -> () {
...
            stamp_pair(&mut &(w), 0, a[(e) as usize], b[(e) as usize], (1.0 / val[(e) as usize]));

&mut &(w) is &mut &[f64; 55], which does not coerce to &mut [f64].

Requirements

  • FR-001: &x passed to a []T parameter that the callee writes lowers to &mut x (or &mut x[..]); a read-only []const T parameter keeps &x.
  • FR-002: The fix lives in the gen-rust lowering (its .t27 home if the pass is ported), with a regression fixture.

Scenarios

  • Given linear.t27, When gen-rust runs, Then the emitted file compiles with rustc and its tests match t27c test-report.
  • Given a read-only slice parameter, When gen-rust runs, Then the call still lowers to a shared borrow.

Boundary

  • In scope: the gen-rust call-argument lowering for slice parameters.
  • Out of scope: other backends; the copy in spice_convert.t27 is removed in a follow-up after this lands.

Success Criteria

  • t27c gen-rust specs/analog/linear.t27 output compiles with rustc.
  • A fixture with a mutable and a read-only slice parameter lowers each correctly.
  • spice_convert.t27 can use analog::linear::{stamp} and drop pair_add / src_add (follow-up).

See #5980 for the gen-rust self-hosting context.

Success Criteria

  • t27c gen-rust specs/analog/linear.t27 | rustc --edition 2021 -o /dev/null - exit 0
  • t27c test specs/analog/linear.t27 exit 0
  • t27c gen-rust specs/tri/collections/array.t27 | rustc --edition 2021 -o /dev/null - exit 0

Activity

  1. added
    shape-refusedClosed by the issue-shape gate (specs/policy/issue_shape.t27); a passing edit reopens it
    on Oct 19, 2026
  2. github-actions commented on Oct 19, 2026

    @github-actions
    Contributor

    Closed by the issue-shape gate (specs/policy/issue_shape.t27, #7498): an issue must have the template's sections. Edit the body; an edit that passes reopens it.

    • missing: ## Success Criteria -- an outcome a machine can settle: a number with a unit, a backticked file, exit 0, or a backticked command
  3. removed
    shape-refusedClosed by the issue-shape gate (specs/policy/issue_shape.t27); a passing edit reopens it
    on Oct 19, 2026
  4. gHashTag commented on Oct 19, 2026

    @gHashTag
    OwnerAuthor

    Reopened by the self-heal of #11007. The issue-shape gate closed this issue with a queued run that judged an older body from its event payload; the current body passes gen/c/policy/issue_shape.c, and the gate's own contract is that a passing body stays open. If the work is in fact finished or obsolete, close it as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions