mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Update ctor from 0.10 to 1.0.6 (#94045)
### What?
Updates the `ctor` crate dependency from `0.10` to `1.0.6` in the
workspace and migrates the two call sites to the new API.
### Why?
We've been running into a rust-analyzer issue with `ctor` 0.10 that the
newer release looks like it should fix. While bumping, the major version
jump also brings in a number of stability and safety improvements
(post-libc-init default priority, required `unsafe` marker, declarative
re-export form, expanded platform support).
### How?
`ctor` 1.x has several breaking changes that affect us:
1. **`#[ctor]` now requires an explicit `unsafe` marker.** Both call
sites were updated:
- `turbopack/crates/turbo-tasks-macros-tests/tests/trybuild.rs`:
`#[ctor::ctor]` → `#[ctor::ctor(unsafe)]`. The function body already
wraps `std::env::remove_var` in `unsafe`, so no further change was
needed.
- `turbopack/crates/turbo-tasks-macros/src/value_impl_macro.rs`: the
proc-macro emits a vtable registration ctor for every
`#[turbo_tasks::value_impl]`. Migrated to the new declarative form (see
next bullet).
2. **`crate_path = ...` is deprecated in favor of
`ctor::declarative::ctor!`.** The ctor 1.0.6 docs explicitly recommend
the declarative macro for crates that re-export ctor (`turbo-tasks`
re-exports it via `macro_helpers::ctor` so user crates don't need a
direct dep). The emission in `value_impl_macro.rs` was rewritten from
```rust
#[turbo_tasks::macro_helpers::ctor::ctor(
crate_path = turbo_tasks::macro_helpers::ctor,
)]
#[allow(non_snake_case)]
fn #vtable_register_ident() { ... }
```
to
```rust
turbo_tasks::macro_helpers::ctor::declarative::ctor! {
#[ctor(unsafe)]
#[allow(non_snake_case)]
fn #vtable_register_ident() { ... }
}
```
3. **Default priority changed.** In 0.x the default priority was `0`
(run before C library init); in 1.x the default is `default` (≈500,
after libc init). We don't specify a priority, and the registration
ctors only push into a `Vec` guarded by a registry — they don't touch
libc — so the later timing is safe and we accept the new default. The
lazy `VTableRegistry::finalize` step (driven by the `VALUES` `LazyLock`)
is unchanged, so visible ordering semantics for downstream code are
preserved.
4. **Other 1.x breaking changes verified as non-issues for this repo:**
- `dtor` was split into its own crate — not used here.
- `priority = naked` syntax removed — not used.
- MSRV bumps: base is 1.60, only the optional `priority` feature
requires 1.85 — we don't enable `priority`.
- `used_linker` / `no_warn_on_missing_unsafe` were replaced by `--cfg
linktime_*` flags — neither was used here.
#### Verification
- `cargo check` / `cargo clippy` clean across `turbo-tasks`,
`turbo-tasks-backend`, `turbo-tasks-macros`, `turbo-tasks-macros-tests`,
and `turbopack-tests`.
- `cargo test -p turbo-tasks-backend`: all tests pass (58 in the largest
suite, 0 failures across all integration tests, 0 doc-test failures).
- `cargo test -p turbopack-tests`: 218 + 87 tests pass, 0 failures, 1
ignored.
#### Lockfile changes
`Cargo.lock` reflects the new dep graph: `ctor` jumps to `1.0.6`,
`link-section` to `0.17.2`, a new `linktime-proc-macro` is pulled in,
and the old `ctor-proc-macro` / `dtor` / `dtor-proc-macro` entries are
dropped (they were transitive deps of `ctor` 0.10).
<!-- NEXT_JS_LLM_PR -->
Co-authored-by: v-work-app[bot] <262237222+v-work-app[bot]@users.noreply.github.com>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Tobias Koppers <[email protected]>
This commit is contained in:
co-authored by
v-work-app[bot] <262237222+v-work-app[bot]@users.noreply.github.com>
Claude
Tobias Koppers
parent
13847b2e9f
commit
11c865c1d6
Generated
+13
-29
@@ -2007,21 +2007,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.10.1"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83cf0d42651b16c6dfe68685716d18480d18a9c39c62d76e8cf3eb6ed5d8bcbf"
|
||||
checksum = "6d765eb1c0bda10d31e0ea185f5ee15da532d60b0912d2bd1441783439e749c5"
|
||||
dependencies = [
|
||||
"ctor-proc-macro",
|
||||
"dtor",
|
||||
"link-section",
|
||||
"linktime-proc-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctor-proc-macro"
|
||||
version = "0.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a949c44fcacbbbb7ada007dc7acb34603dd97cd47de5d054f2b6493ecebb483"
|
||||
|
||||
[[package]]
|
||||
name = "cty"
|
||||
version = "0.2.2"
|
||||
@@ -2387,21 +2380,6 @@ dependencies = [
|
||||
"dtoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtor"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edf234dd1594d6dd434a8fb8cada51ddbbc593e40e4a01556a0b31c62da2775b"
|
||||
dependencies = [
|
||||
"dtor-proc-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtor-proc-macro"
|
||||
version = "0.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2647271c92754afcb174e758003cfd1cbf1e43e5a7853d7b1813e63e19e39a73"
|
||||
|
||||
[[package]]
|
||||
name = "dunce"
|
||||
version = "1.0.4"
|
||||
@@ -4200,9 +4178,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "link-section"
|
||||
version = "0.2.1"
|
||||
version = "0.17.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b685d66585d646efe09fec763d796c291049c8b6bf84e04954bffc8748341f0d"
|
||||
checksum = "4d1e908a416d6e9f725743b84a36feea40c4c131e805fbc26d61f9f451f36080"
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
@@ -4219,6 +4197,12 @@ dependencies = [
|
||||
"linked-hash-map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linktime-proc-macro"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a44cd706ff0d503ee32b2071166510ca27e281228de10cd3aa8d35ff94560f81"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.14"
|
||||
@@ -9825,7 +9809,7 @@ dependencies = [
|
||||
"bincode 2.0.1",
|
||||
"codspeed-criterion-compat",
|
||||
"concurrent-queue",
|
||||
"ctor 0.10.1",
|
||||
"ctor 1.0.6",
|
||||
"dashmap 6.1.0",
|
||||
"either",
|
||||
"erased-serde",
|
||||
@@ -10050,7 +10034,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode 2.0.1",
|
||||
"ctor 0.10.1",
|
||||
"ctor 1.0.6",
|
||||
"serde",
|
||||
"tokio",
|
||||
"trybuild",
|
||||
|
||||
+1
-1
@@ -258,7 +258,7 @@ console-subscriber = "0.4.1"
|
||||
const_format = "0.2.30"
|
||||
crc32fast = "1.5.0"
|
||||
criterion = { package = "codspeed-criterion-compat", version = "4.3.0" }
|
||||
ctor = "0.10"
|
||||
ctor = "1.0.6"
|
||||
crossbeam-channel = "0.5.8"
|
||||
crossbeam-utils = "0.8"
|
||||
dashmap = "6.1.0"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// trybuild's stderr snapshot comparisons. Unsetting it here means only the
|
||||
// sub-compilations trybuild spawns are affected — the main test binary was already
|
||||
// compiled with sccache.
|
||||
#[ctor::ctor]
|
||||
#[ctor::ctor(unsafe)]
|
||||
fn unset_rustc_wrapper() {
|
||||
unsafe { std::env::remove_var("RUSTC_WRAPPER") };
|
||||
}
|
||||
|
||||
@@ -317,21 +317,21 @@ pub fn value_impl(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
// there's no runtime `transmute` or indirect fn call.
|
||||
|
||||
#[cfg(not(rust_analyzer))]
|
||||
#[turbo_tasks::macro_helpers::ctor::ctor(
|
||||
crate_path = turbo_tasks::macro_helpers::ctor,
|
||||
)]
|
||||
#[allow(non_snake_case)]
|
||||
fn #vtable_register_ident() {
|
||||
<::std::boxed::Box<dyn #trait_path> as turbo_tasks::VcValueTrait>::IMPL_VTABLES
|
||||
.register(
|
||||
<#ty as turbo_tasks::macro_helpers::RegistryDef::<turbo_tasks::ValueType>>::DEF,
|
||||
{
|
||||
let p: *const #ty = ::std::ptr::null();
|
||||
// This attaches a fat pointer to the null pointer.
|
||||
let fat: *const dyn #trait_path = p;
|
||||
fat
|
||||
},
|
||||
);
|
||||
turbo_tasks::macro_helpers::ctor::declarative::ctor! {
|
||||
#[ctor(unsafe)]
|
||||
#[allow(non_snake_case)]
|
||||
fn #vtable_register_ident() {
|
||||
<::std::boxed::Box<dyn #trait_path> as turbo_tasks::VcValueTrait>::IMPL_VTABLES
|
||||
.register(
|
||||
<#ty as turbo_tasks::macro_helpers::RegistryDef::<turbo_tasks::ValueType>>::DEF,
|
||||
{
|
||||
let p: *const #ty = ::std::ptr::null();
|
||||
// This attaches a fat pointer to the null pointer.
|
||||
let fat: *const dyn #trait_path = p;
|
||||
fat
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(alexkirsz) We can't have a general `turbo_tasks::Upcast<Box<dyn Trait>> for T where T: Trait` because
|
||||
|
||||
Reference in New Issue
Block a user