build: bump Rust toolchain to nightly-2026-07-20

Closed
RO
4mo ago
+117-106

Bumps the pinned Rust nightly from nightly-2026-05-06 to nightly-2026-07-20.

oldnew
rustc1.97.0-nightly (e95e73209 2026-05-05)1.99.0-nightly (9f36de775 2026-07-19)
bundled LLVM22.1.422.1.8

Notable upstream changes in this range

  • v0 symbol mangling is now the default (rust#151994, 1.97). Rust symbols are now emitted with the _R prefix instead of legacy _ZN. std's own backtrace printer demangles both, but bun.report's server-side remapper and any external profiler/debugger tooling that reads Bun's Rust frames needs a v0-aware demangler. We do not pin -Csymbol-mangling-version, so this takes effect.
  • linker_messages lint on by default (rust#153968, 1.97). Already handled: scripts/build/rust.ts and scripts/build/cargo-config.ts pass -Alinker_messages.
  • Bundled LLVM 22.1.4 → 22.1.8 (same major). Cross-language LTO against our clang-21 is unaffected; the rust-lto-fix step still reads rustc-emitted bitcode with rustc's own llvm-tools.
  • Windows WSAESHUTDOWN now maps to io::ErrorKind::BrokenPipe (rust#156063, 1.97). N/A for us: Bun's socket layer maps Win32 errors through bun_errno (which already maps WSAESHUTDOWN → EPIPE), not std's ErrorKind.
  • Enum layout encoding changed for some repr(Rust) enums (rust#155473, 1.97). N/A: every enum we pass across FFI is repr(C)/repr(u*).
  • {integer}::isolate_lowest_one / isolate_highest_one stabilised (1.97). Used in two of the clippy fixes below.
  • core::mem::type_info nightly feature reshaped: core::intrinsics::type_id is now #[rustc_comptime] (compile-time only), and type_info::Type lost its size field in favour of TypeId::size(). bun_collections::MultiArrayList is the only user; fixed below.
  • Of the nightly features we enable (adt_const_params, allocator_api, arbitrary_self_types_pointers, generic_const_exprs, hasher_prefixfree_extras, inherent_associated_types, macro_metavar_expr, sync_unsafe_cell, thread_local, type_info, core_intrinsics), only type_info/core_intrinsics changed shape.
  • New rustc lint suspicious_runtime_symbol_definitions (1.99 nightly). Flags extern "C" declarations of runtime symbols (exit, etc.) whose Rust signature differs from std's own. Our bun_core::Global declares libc_exit as safe fn on purpose (no memory-safety preconditions); the ABI is identical, so #[allow] on the block.

Toolchain pin

  • rust-toolchain.toml
  • .github/workflows/{format,clippy,miri}.yml (RUSTUP_TOOLCHAIN)

Nightly API changes (core::mem::type_info)

bun_collections::MultiArrayList uses the experimental reflection API, which changed shape:

  • core::intrinsics::type_id is now #[rustc_comptime] (callable only at compile time). Wrapped the call in a const { } block.
  • type_info::Type no longer has a size field; the size now comes from TypeId::size().

New clippy lints

The new nightly promotes several lints that trip under the workspace's -D warnings. All fixes are mechanical and preserve behaviour:

  • clippy::needless_late_init: convert late let x; if ... { x = ... } else { x = ... } to let x = if ... { ... } else { ... }; (bun_alloc, bun_collections, js_parser, js_printer, install, runtime/node/path, runtime/socket/udp, valkey_jsc, sql_jsc/mysql)
  • clippy::chunks_exact_to_as_chunks: replace .chunks_exact(N) / .chunks_exact_mut(N) on const N with .as_chunks::<N>() (bun_core, boringssl, ast/char_freq, http_jsc websocket, runtime/cli/upgrade, runtime/image, runtime/webcore/encoding)
  • clippy::manual_isolate_lowest_one: x & x.wrapping_neg() → x.isolate_lowest_one() (collections, css)
  • clippy::manual_clear: truncate(0) → clear() (router)
  • clippy::drain_collect: vec.drain(..).collect() → mem::take(&mut vec) (react_compiler)

Quiet rustup output

The build runs rustup toolchain install --force before cargo to self-heal partial toolchain installs. On a no-op this printed:

info: syncing channel updates for 'nightly-...-aarch64-apple-darwin'
info: latest update on ...
info: component 'rust-src' is up to date
info: self-update is disabled for this build of rustup
info: any updates to rustup will need to be fetched with your system package manager

Added -q (sets rustup log level to WARN) and --no-self-update to the three call sites (scripts/build/{rust.ts,source.ts,tools.ts}) so the info lines are suppressed while download/error output still surfaces.

Verification

  • bun bd builds and bun-debug --revision runs
  • cargo fmt --all --check is clean on the new nightly (no formatting drift)
  • cargo clippy --workspace --no-deps --keep-going passes on the new nightly
  • cargo test -p bun_collections multi_array passes (7/7)

Fixes #31414