### What?
Adds a CI job that runs selected Rust unit tests under
[Miri](https://github.com/rust-lang/miri) to detect undefined behavior
in unsafe code.
The job currently covers the low-level crates that are compatible with
Miri:
- `turbo-persistence`
- `turbo-rcstr`
- `turbo-tasks-malloc`
It also makes those crates Miri-compatible by:
- using provenance-free tagged-pointer operations in `turbo-rcstr`;
- disabling mimalloc and native compression under Miri;
- making mmap support a default-enabled Cargo feature that is disabled
for Miri and wasm;
- running persistence through file I/O when mmap is disabled;
- skipping only tests measured to exceed the Miri time budget;
- removing leaked test arenas from the analyzer predicate tests.
### Why?
Miri can detect invalid memory access and other undefined behavior that
normal Rust tests may not expose. Running it in CI gives low-level
unsafe code an additional correctness check.
The job uses an explicit package allowlist because Turbo Tasks builds
its generated registry from linker sections, and Miri does not support
the linker-defined section symbols required by that registry.
### How?
- Installs the `miri` Rust component in CI and the development
container.
- Adds a dedicated `test-cargo-unit-miri` task and reusable workflow
configuration.
- Makes `memmap2` optional behind the default `mmap` feature and
disables that feature in Miri CI and the wasm dependency graph.
- Uses structural `cfg(miri)` branches for allocator and compression
paths Miri cannot execute.
- Re-enables three persistence compaction tests after measuring them
successfully under Miri.
- Keeps normal native behavior unchanged and documents measured Miri
exclusions at the affected tests.
Verification included focused normal and Miri tests for persistence,
rcstr, allocation accounting, compression, and the refactored leak-free
predicate cases.
<!-- NEXT_JS_LLM -->
<!-- fleet fb42942f-173a-484c-b4de-4e18354834c6 -->
---------
Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
This updates to nightly-2026-07-29
---------
Co-authored-by: vercel-fleet[bot] <308483924+vercel-fleet[bot]@users.noreply.github.com>
Co-authored-by: Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
Bump rust nightly version
Critically this fixes a bug in Rust Analyzer where it didn't understand
'pattern_types' a new rust feature that is used by `NonZero<T>` types
for example)

So now we can get feedback on the size of types containing vc!
From scanning release notes there is nothing major that i can see.
Clippy did flag one new warning that is being addressed as well.
It compiles fine, but we have another problem: `cargo fmt` really doesn't like it
```
cargo fmt -- turbopack/crates/turbo-tasks-fs/src/lib.rs
error: let chains are only allowed in Rust 2024 or later
--> /Users/niklas/code/next.js/turbopack/crates/turbo-tasks-fs/src/lib.rs:749:44
|
749 | if create_directory && let Some(parent) = full_path.parent() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: let chains are only allowed in Rust 2024 or later
--> /Users/niklas/code/next.js/turbopack/crates/turbo-tasks-fs/src/lib.rs:893:44
|
893 | if create_directory && let Some(parent) = full_path.parent() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: let chains are only allowed in Rust 2024 or later
--> /Users/niklas/code/next.js/turbopack/crates/turbo-tasks-fs/src/lib.rs:1233:12
|
1233 | if let Some(path) = join_path(&self.path, path)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
The precommit hook that selectively runs on files is simply not a supported usecase.
So I changed that to `rustfmt --edition 2024 -- ` now 🤷
Previous discussion: https://vercel.slack.com/archives/C03EWR7LGEN/p1748898285716779
Devcontainers support custom `Dockerfile`s, but it seems like it's more recommended to use a base image with "features" on top: https://containers.dev/implementors/features/
Features get applied after the `Dockerfile`, so e.g. if we're installing `rust` with a feature, then we can't install things that depend on `rust` (e.g. `cargo-nextest`: https://nexte.st/) in the `Dockerfile`. So you're forced to do things with features instead, which can specify dependencies and ordering requirements.
I removed a bunch of comments that were left over from the template. People wishing to update this file should refer to the https://aka.ms/devcontainer.json link at the top of the file.
Also added a lockfile for the features, generated with:
```
devcontainer upgrade --workspace-folder=.
```
**Note:** The `base.Dockerfile` here was entirely unused.
### Testing
```
podman stop --all && podman rm --all # replace podman with docker if you're using docker
devcontainer up --workspace-folder=.
devcontainer exec --workspace-folder=. zsh
```