Skip to content

Attempting to run a benchmark with the "▶Run" lens fails #22515

@SludgePhD

Description

@SludgePhD

rust-analyzer version: 0.3.2921-standalone

rustc version: shouldn't matter

editor or extension: VS Code

relevant settings: none

code snippet to reproduce:

// benches/bench.rs
fn main() {}

Clicking the "▶Run" lens results in this terminal output:

error: unexpected argument '--bench' found

  tip: to pass '--bench' as a value, use '-- --bench'

Usage: cargo run --package [<SPEC>] [ARGS]...

For more information, try '--help'.

It looks like #21948 was never properly fixed, and instead the run button went from being absent to being non-functional.

Like integration tests, benchmarks cannot be run with cargo run (cargo run only supports binaries and examples). rust-analyzer correctly handles this for integration tests by invoking cargo test instead, but not for benchmarks, which need to be invoked through cargo bench.

The same problem occurs when the "rust-analyzer: Run" command in used inside the benchmark.

rust-analyzer already has the rust-analyzer.runnables.bench.command, the "Subcommand used for bench runnables instead of bench." which correctly defaults to bench, and which I haven't changed. Is this setting just ignored, or does it have other uses?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-vscodevscode plugin issuesC-bugCategory: bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions