mirror of
https://github.com/hanzoai/swc.git
synced 2026-10-30 19:42:53 +00:00
## Summary - update the repo root `rust-toolchain` to `nightly-2026-04-10` - keep fixture-local toolchains unchanged - apply compatibility fixes needed to keep making progress on latest-nightly validation ## Verification - `git submodule update --init --recursive` - `cargo fmt --all` - `cargo clippy --all --all-targets -- -D warnings` *(currently failing with additional latest-nightly lint fallout in `swc_css_minifier` and `swc_css_codegen`)* - `cargo test -p swc_allocator --features nightly` *(currently failing in external dependency `bumpalo 3.19.0` with `AllocErr`/`AllocError` type mismatch)* ## Notes - this PR is draft because the nightly upgrade exposes more follow-up fixes than the initial toolchain pin bump - root toolchain bump and the first round of compatibility cleanup are included here so the remaining work can be reviewed incrementally
45 lines
924 B
Rust
45 lines
924 B
Rust
#![cfg(feature = "nightly")]
|
|
#![feature(allocator_api)]
|
|
|
|
use std::{alloc::Global, boxed::Box, vec::Vec};
|
|
|
|
use criterion::black_box;
|
|
use swc_allocator::allocators::Arena;
|
|
|
|
#[test]
|
|
fn direct_alloc_std() {
|
|
let mut buf = std::vec::Vec::new();
|
|
for i in 0..1000 {
|
|
let item: std::boxed::Box<usize> = black_box(std::boxed::Box::new(black_box(i)));
|
|
buf.push(item);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn direct_alloc_in_arena() {
|
|
let arena = Arena::default();
|
|
let mut vec: Vec<Box<usize, &Arena>, &Arena> = Vec::new_in(&arena);
|
|
|
|
for i in 0..1000 {
|
|
let item = black_box(Box::new_in(black_box(i), &arena));
|
|
vec.push(item);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn escape() {
|
|
let arena = Arena::default();
|
|
let obj = Box::new_in(1234, &arena);
|
|
|
|
assert_eq!(*obj, 1234);
|
|
drop(obj);
|
|
}
|
|
|
|
#[test]
|
|
fn global_allocator_escape() {
|
|
let obj = Box::new_in(1234, Global);
|
|
|
|
assert_eq!(*obj, 1234);
|
|
drop(obj);
|
|
}
|