Files
Tobias KoppersGitHubv-work-app[bot] <262237222+v-work-app[bot]@users.noreply.github.com>ClaudeTobias Koppers
11c865c1d6 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]>
2026-06-01 14:25:48 +02:00

45 lines
1.3 KiB
Rust

// Unset RUSTC_WRAPPER before trybuild tests run. When sccache wraps rustc, it
// emits "warning: ignoring -C extra-filename flag due to -o flag" which pollutes
// 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(unsafe)]
fn unset_rustc_wrapper() {
unsafe { std::env::remove_var("RUSTC_WRAPPER") };
}
#[test]
fn derive_operation_value() {
let t = trybuild::TestCases::new();
t.pass("tests/derive_operation_value/pass_*.rs");
t.compile_fail("tests/derive_operation_value/fail_*.rs");
}
#[test]
fn derive_non_local_value() {
let t = trybuild::TestCases::new();
t.pass("tests/derive_non_local_value/pass_*.rs");
t.compile_fail("tests/derive_non_local_value/fail_*.rs");
}
#[test]
fn function() {
let t = trybuild::TestCases::new();
t.pass("tests/function/pass_*.rs");
t.compile_fail("tests/function/fail_*.rs");
}
#[test]
fn value() {
let t = trybuild::TestCases::new();
t.pass("tests/value/pass_*.rs");
t.compile_fail("tests/value/fail_*.rs");
}
#[test]
fn value_trait() {
let t = trybuild::TestCases::new();
t.pass("tests/value_trait/pass_*.rs");
t.compile_fail("tests/value_trait/fail_*.rs");
}