Files
Luke SandbergandGitHub 38c4caf22a [turbopack] Don't execute inventory_submit in rust analyzer (#83447)
### What?
In #83074 we changed how turbo task objects were registered to use the `inventory` crate.
This PR adds a new `inventory_submit!` macro that wraps the existing `inventory::submit` function with a `#[cfg(not(rust_analyzer))]` attribute to prevent Rust Analyzer choking on the generated code.

See example error

![image.png](https://app.graphite.dev/user-attachments/assets/2fe87f23-8717-4615-a86d-94c1b19ae099.png)

Because the inventory code does not affect any API surfaces this is safe and if anything should improve rust-analyzer performance
2025-09-04 13:31:50 -07:00

23 lines
653 B
Rust

#![allow(unexpected_cfgs)]
use anyhow::Result;
use turbo_tasks::{OperationVc, ResolvedVc, Vc};
#[turbo_tasks::function(operation)]
fn bare_op_fn() -> Vc<i32> {
Vc::cell(21)
}
// operations can take `ResolvedVc`s too (anything that's a `NonLocalValue`).
#[turbo_tasks::function(operation)]
async fn multiply(value: OperationVc<i32>, coefficient: ResolvedVc<i32>) -> Result<Vc<i32>> {
Ok(Vc::cell((*value.connect().await?) * (*coefficient.await?)))
}
#[allow(dead_code)]
fn use_operations() {
let twenty_one: OperationVc<i32> = bare_op_fn();
let _forty_two: OperationVc<i32> = multiply(twenty_one, ResolvedVc::cell(2));
}
fn main() {}