zed-industries/zed · error · syn::Error

#[gpui::bench] does not support async benchmark functions ye

Error message

#[gpui::bench] does not support async benchmark functions yet

What it means

Compile-time rejection: the #[gpui::bench] macro was applied to an async fn, which the benchmark harness does not support. The attribute cannot generate a synchronous Criterion benchmark for an async function.

Source

Thrown at crates/gpui_macros/src/bench.rs:64

        if let Err(error) = parser.parse(args) {
            return error_to_stream(error);
        }
    }

    // The frame budget math lives in `BenchReport` so `bench_context` is the
    // single source of truth; `default()` supplies the default frame rate.
    let report_expr = match fps {
        Some(fps) => quote! { gpui::BenchReport::with_fps(#fps) },
        None => quote! { gpui::BenchReport::default() },
    };

    let mut inner_fn = match syn::parse::<ItemFn>(function) {
        Ok(function) => function,
        Err(error) => return error_to_stream(error),
    };

    if let Some(asyncness) = &inner_fn.sig.asyncness {
        return error_to_stream(syn::Error::new(
            asyncness.span(),
            "#[gpui::bench] does not support async benchmark functions yet",
        ));
    }

    let outer_fn_name = inner_fn.sig.ident.clone();
    let inner_fn_name = format_ident!("__gpui_bench_{}", outer_fn_name);
    inner_fn.sig.ident = inner_fn_name.clone();

    let benchmark = if let Some(inputs) = inputs {
        let input_name = match input_name {
            Some(input_name) => quote! { #input_name },
            None => quote! { stringify!(#outer_fn_name) },
        };
        let group_name = match group_name {
            Some(group_name) => quote! { #group_name },
            None => quote! { stringify!(#outer_fn_name) },
        };

View on GitHub (pinned to f4178619ac)

Solutions

  1. Make the benchmark function synchronous
  2. If async setup is needed, drive it manually (e.g. via a runtime handle) inside the sync benchmark body
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/gpui_macros/src/bench.rs:64 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/fd21d4d0e6cb9e0c. Report an issue: GitHub.