Skip to content

[bug] t27c gen-rust: the use splice matches words inside string literals and pulls in a whole module (13,432 vs 4,111 lines) #10824

Open

Description

@gHashTag

Summary

t27c gen-rust's use splice decides which used module's code to pull into the generated file by matching words, and it matches words inside string literals. In specs/tools/t27o/zig_convert.t27 (PR #10819) a string literal containing convert or at line pulled the whole Rust front end into gen/rust/tools/t27o/zig_convert.rs: 13,432 lines instead of 4,111. The lane worked around it by writing those strings in two pieces.

Expected vs actual

Expected: the splice follows identifiers the spec references, never text inside a string literal. Actual: a literal that happens to contain a used module's fn name pulls that module in.

Steps to reproduce

A spec that uses one fn of a module (use tools::t27o::rust_convert::puts;) and has a string literal containing another of that module's fn names; run t27c gen-rust and count lines with and without the literal.

Risks / severity

Medium: silent bloat of generated code (and of every crate that includes it by #[path]); the workaround (split strings) is invisible to the next reader. Related: #10556 (two imported modules that each declare a helper of the same name make the splicer drop both).

Boundary

  • May touch: the gen-rust splice in the compiler (bootstrap/src/compiler.rs or its spec, per the FROZEN_HASH port rule), a regression fixture.

Links

#10819, #10765, #10556, #5980.

User Scenarios

  • Given a spec specs/tools/t27o/zig_convert.t27 that uses tools::t27o::rust_convert::puts and contains a string literal with the word convert, When t27c gen-rust runs, Then the generated gen/rust/tools/t27o/zig_convert.rs must not include code for tools::t27o::rust_convert::convert (the file stays near 4,111 lines, not 13,432).

Requirements

  • FR-001: The gen-rust use-splice MUST identify referenced identifiers by parsing the spec's AST, not by textual word matching.
  • FR-002: The splice MUST ignore tokens that appear inside string literals, character literals, or comments.
  • FR-003: A regression test fixture MUST be added that fails before the fix and passes after, exercising a spec with a literal containing a used module's function name.

Success Criteria

  • t27c gen-rust specs/tools/t27o/zig_convert.t27 produces gen/rust/tools/t27o/zig_convert.rs with ≤ 4,500 lines (wc -l gen/rust/tools/t27o/zig_convert.rs exits 0 and shows ≤ 4500).
  • The new regression fixture in the test suite runs and exits 0 (cargo test -p t27c gen_rust_splice_ignores_string_literals exits 0).
  • No existing gen-rust tests regress (cargo test -p t27c gen_rust exits 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: ## User Scenarios -- at least one Given/When/Then scenario
    • missing: ## Requirements -- numbered obligations, FR-001: ... MUST ...
    • 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

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions