Skip to content

Consumed map/set keys are moved; migrator macro capture and probe fixed (#2265) - #2267

Merged
ehartford merged 1 commit into
mainfrom
macro-cache
Oct 8, 2026
Merged

ehartford merged 1 commit into
mainfrom
macro-cache

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Fixes #2265. Three layered bugs, found with the debugger and temporary diagnostics (none committed):

  • Move checker (safety). HashMap.remove, increment, decrement and HashSet.remove take an owned key that MIR lowers as a move, but Sema never marked the binding moved. let a = mk(); m.remove(a); print(a) compiled and printed an empty string. Sema now marks it (beside the store rule insert already uses). Four compile-error tests fail on main and pass here. The only violation in the tree was the migrator.
  • Migrator capture. ci_capture_macro_values used name after remove(name), so every macro landed under the key "" and the per-file cache was empty. That made a macro's translation depend on which names other paths had looked up. insert already replaces, so the remove is gone.
  • Macro probe. Every pcre2 unit's clang probe hit clang's default 20-error limit; its location-less "too many errors emitted" read as a header error and discarded the whole batch. Parses now pass -ferror-limit=0.

Corpora. Regenerated with each corpus's own test suite passing before promotion. pcre2's defs now carry clang's typed, folded constants (and some constants the text fallback could not spell); zlib folds three constants and names EWOULDBLOCK as its source does (defined per target in std.libc).

Gate, deep-debug-tool-tests and drop-audit green.

Open question for Eric (not changed here): D22 leaves the key mode of remove to the map's API. Today it consumes the key, so m.remove(k) followed by a use of k needs m.remove(k.clone()). get/contains observe their key. Making remove observe too would match them and Rust's remove(&Q).

…e is moved; the migrator's macro capture and probe work again (#2265)

Three layered bugs. Sema never marked the owned key of those builtins
moved while MIR lowered it as a move, so a later use compiled and read the
blanked string. The migrator's capture used `name` after
`remove(name)`, so every macro was stored under "" and its literal
fallback depended on which names other paths happened to look up. And
every pcre2 unit's clang probe hit clang's 20-error limit, whose
location-less note read as a header error and discarded the whole batch.

Sema marks those keys moved (four compile-error tests); the capture drops
the needless remove (insert replaces); parses pass -ferror-limit=0. The
corpora are regenerated: constants now carry clang's typed, folded values,
and every corpus passes its own tests.
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on f51fcec (gate, uat, battery-checks: fixpoint, drop and move audits, every test target).

@ehartford
ehartford marked this pull request as ready for review October 8, 2026 09:44
@ehartford
ehartford merged commit 1917e05 into main Oct 8, 2026
@ehartford
ehartford deleted the macro-cache branch October 8, 2026 09:45
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.

Migrator: a function-like macro's translation depends on earlier macro lookups (cache side effect)

1 participant