Commit Graph

11 Commits

Author SHA1 Message Date
Niklas Mischkulnig 3bf71ee3fd test: run cargo unit tests with miri as well (#97535)
### 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>
2026-09-18 09:29:06 +02:00
Niklas Mischkulnig 3dd04f117c Upgrade rustc to nightly-2026-08-20 (#97665)
All platform build run:
https://github.com/vercel/next.js/actions/runs/32464645938
2026-08-26 10:14:46 +00:00
Will Binns-Smith 1c39fcafdb Update Rust toolchain to nightly-2026-07-29 (#96365)
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>
2026-07-30 15:11:40 -07:00
Luke Sandberg b2add075ae Bump Rust toolchain (#95205)
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)


![image.png](https://app.graphite.com/user-attachments/assets/04c3a119-d08b-457a-bd55-6fe94da24806.png)

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.
2026-06-26 10:11:02 -07:00
Niklas Mischkulnig 55b2d3c744 Upgrade rustc to nightly-2026-05-15 (#94021) 2026-05-21 20:26:11 +02:00
Will Binns-Smith d6906eabd6 Update Rust toolchain to nightly-2026-04-02 (#92288) 2026-04-03 17:27:59 -07:00
Benjamin Woodruff 5563b4d7e1 Turbopack: Update rust toolchain to nightly-2026-02-18 (#89974)
Rust finally merged a fix to the "trying to encode a dep node twice" ICE we seem to most frequently run into, triggered by the rustc parallel frontend feature: https://github.com/rust-lang/rust/pull/151509

- @mischnic  commented on the issue: https://github.com/rust-lang/rust/issues/150018#issuecomment-3754877064
- @mischnic just updated our toolchain last week, but I'd like to get this fix in.

CI Job for build-and-release that covers all platforms: https://github.com/vercel/next.js/actions/runs/22156881743  
  
In the process of this upgrade, I found and reported https://github.com/rust-lang/rust/issues/152735 upstream (fixed `nightly-2026-02-18`).
2026-02-18 15:41:22 -08:00
Niklas Mischkulnig 6dfcffe1cf Upgrade rustc to 2026-02-05 (#89591)
- checked_div 
- loop -> while
2026-02-06 21:03:00 +01:00
Niklas Mischkulnig 507194aa64 Upgrade to rustc 2026-01-04 (#88095) 2026-01-08 09:30:10 +01:00
Niklas Mischkulnig c2081b134e Bump Rust to nightly-2025-09-21 (#83415)
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
2025-09-23 17:15:44 +02:00
Benjamin Woodruff 3e750d104f Devcontainer: Replace Dockerfile with prebuilt image+features (#82450)
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
```
2025-08-08 10:14:30 -07:00