Skip to content

fix(rust): str is borrowed in both siblings and owned only here (+26) - #3240

Merged
gHashTag merged 6 commits into
masterfrom
strfix
Sep 5, 2026
Merged

gHashTag merged 6 commits into
masterfrom
strfix

Conversation

@gHashTag

@gHashTag gHashTag commented Sep 5, 2026

Copy link
Copy Markdown
Owner

t27_type_to_rust maps the spec type str to the owned String. Both sibling
backends map it to a borrowed form — Zig writes []const u8 (compiler.rs:8322)
and C writes const char* — and Rust's borrowed spelling is &'static str.

The owned mapping is not constructible in a const item, which is where most specs
use it:

error[E0308]: mismatched types
pub const DEFAULT_NOTEBOOK: String = "t27-QUEEN-BRAIN";
                            ------   ^^^^^^^^^^^^^^^^^ expected `String`, found `&str`

48 of the 75 specs whose first error is E0308 carry this exact mismatch.

Measured, 650 corpus specs, by name

rustc accepts, before 288
after 314
gain +26
regressions 0

The judgement, stated

&'static str is narrower than String: a field of that type can only hold a string
that lives for the program. That narrowing is what both siblings already chose —
neither []const u8 nor const char* owns its bytes — and it is the only spelling
that works in the const position the corpus actually uses. Zero regressions across
650 specs says nothing in the corpus needed the owned form.

A correction to my own predictor

#3219 established that the yield of a fix tracks the stub-bodied share of its
class. This class is 3% stub-bodied (20 of 797 functions), so I predicted +2 to
+8
and measured +26.

The rule needed a boundary it did not have. It applies to a fix that repairs a
signature while leaving a body behind — there, a real body carries further defects
and the fix cannot clear the file. It does not apply to a fix that repairs a
complete declaration: pub const X: T = literal; is correct or not on its own, and
no body's state bears on it. Consts are why this class cleared 26 files whose bodies
are not stubs at all.

Closes #3239

compiler.rs:8322 maps "str" | "string" to []const u8 for Zig and
compiler.rs:18248 maps it to const char* for C. compiler.rs:24426 mapped it to
the owned String for Rust, and String is not constructible in a `const` item,
which is where the corpus mostly uses it:

    pub const DEFAULT_NOTEBOOK: String = "t27-QUEEN-BRAIN";
    error[E0308]: expected `String`, found `&str`

48 of the 75 specs whose first error was E0308 carried that mismatch.

Measured by name over all 650 corpus specs: rustc accepts 288 -> 314, +26, zero
regressions.

The judgement is stated rather than hidden. `&'static str` is narrower than
String -- a field of that type holds only a string living for the program -- and
that narrowing is what both siblings already chose, neither []const u8 nor
const char* owning its bytes. Zero regressions says nothing in the corpus needed
the owned form.

Also records the boundary my predictor from #3219 was missing. That rule ties a
fix's yield to the stub-bodied share of its class; this class is 3% stub-bodied
and I predicted +2..+8 against a measured +26. The rule holds for a fix repairing
a SIGNATURE while leaving a body, and not for one repairing a COMPLETE
DECLARATION: a const is correct or not on its own.

Seal and 92 drifted seals move in the same commit.

Closes #3239

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 03:37:09 UTC

Summary

Status Count
Total Open PRs 19
PRs with Failing Checks 12
PRs with All Checks Green 7
READY 0
FAILING 12
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=a65bd1180be9 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 04:10:35 UTC

Summary

Status Count
Total Open PRs 21
PRs with Failing Checks 14
PRs with All Checks Green 7
READY 0
FAILING 14
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=a65bd1180be9 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 05:18:23 UTC

Summary

Status Count
Total Open PRs 21
PRs with Failing Checks 17
PRs with All Checks Green 4
READY 0
FAILING 17
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=a65bd1180be9 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 05:49:37 UTC

Summary

Status Count
Total Open PRs 20
PRs with Failing Checks 16
PRs with All Checks Green 4
READY 0
FAILING 16
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=a65bd1180be9 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 06:05:00 UTC

Summary

Status Count
Total Open PRs 19
PRs with Failing Checks 17
PRs with All Checks Green 2
READY 0
FAILING 17
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=a65bd1180be9 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 06:16:33 UTC

Summary

Status Count
Total Open PRs 18
PRs with Failing Checks 16
PRs with All Checks Green 2
READY 1
FAILING 16
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=a65bd1180be9 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@gHashTag
gHashTag merged commit 1a96fec into master Sep 5, 2026
30 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

str is borrowed in both sibling backends and owned only in Rust, where a const cannot hold it

1 participant