Files
rust/compiler/rustc_data_structures
Jacob Pratt 976acb04b6 Rollup merge of #157620 - Daniel-B-Smith:smithdb3/fileencoder-strategy, r=cjgillot
Add a strategy FnMut to inject behavior into the flush cycle

This PR adds the interface needed to avoid forking FileEncoder in https://github.com/rust-lang/rust/pull/154724.

This adds a FnMut used as a strategy/observer to see the bytes being flushed to disk. For https://github.com/rust-lang/rust/pull/154724, that would be used to calculate the metadata hash on the raw metadata bytes.

The 'static hack is pretty ugly, but otherwise, the FileEncoder lifetime goes exceptionally viral and requires some very unfortunate workarounds to avoid self referential lifetimes. That's a bit of a timebomb if the wrong FileEncoder client tries to use the new API, but the worst case outcome is a wild goose chase of lifetime chasing.

Full disclosure: I used Claude Code to generate much of the PR. I have fully reviewed the code and stand behind it.

r? @cjgillot
2026-06-11 00:34:03 -04:00
..