rust-analyzer tools: workspace-wide extra Bazel flags

Open
#4,505 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start by reading the rust-analyzer tool entry points discover_rust_project, gen_rust_project, and flycheck, which the issue says run bazel info and bazel build. Trace how their existing bazel_args are passed and how the proposed //tools/rust_analyzer:extra_bazel_args build setting could reach those calls. Done means workspace .bazelrc configuration supplies extra flags to every relevant Bazel invocation, with documentation and coverage for the tools.

Written by the indexing model from the issue text.

Description

needs-triage

The rust-analyzer tools (discover_rust_project, gen_rust_project, flycheck) run bazel info and bazel build in the workspace, so they pick up the workspace .bazelrc. If that rc adds output groups or aspects to every build, for example clippy and other linters through --output_groups and --aspects, discovery builds them for every crate and gets much slower.

The tools already take bazel_args on their command line, but those have to be passed in each editor's config, by every developer. We'd like to set them once for the workspace.

What we run with is a repeatable string build setting, //tools/rust_analyzer:extra_bazel_args. It's read when the tools are built and added to every bazel info / bazel build they run, so a workspace sets it once in its .bazelrc:

common --@rules_rust//tools/rust_analyzer:extra_bazel_args=--config=ide

Is that something you'd take? If so I can send the PR, with docs. If you'd prefer another mechanism (an env var, or a file the tools read), I'm happy to do that instead.

Dominant language
Starlark
Stars
857
Forks
701
Avg merge
4d 7h
Merged PRs (30d)
46

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_rust

All issues in bazelbuild/rules_rust

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.