Skip to content

Tolerate partial build failures during rust-analyzer discovery#4127

Merged
UebelAndre merged 1 commit into
bazelbuild:mainfrom
mgeisler:rust-analyzer-discover-keep-going
Jul 3, 2026
Merged

Tolerate partial build failures during rust-analyzer discovery#4127
UebelAndre merged 1 commit into
bazelbuild:mainfrom
mgeisler:rust-analyzer-discover-keep-going

Conversation

@mgeisler

@mgeisler mgeisler commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

discover_bazel_rust_project builds the rust-analyzer aspect over the whole workspace and bailed on any non-zero Bazel exit. In a large monorepo a single broken target (e.g. an unrelated, unmaintained one) aborted the build, leaving rust-analyzer with no Bazel project model. It then silently falls back to a Cargo workspace, which breaks proc-macro expansion (toolchain ABI mismatch) and materializes a stray target/.

Pass --keep_going so Bazel keeps building the rest of the graph, and treat the result as usable when the BEP still yielded crate specs: proceed with a log::warn that the project may be incomplete, and only fail when zero specs were produced. This mirrors flycheck's existing exit-code handling.

Add an end-to-end test that stands up a workspace with one good rust_library and one target that fails analysis, then checks discovery still returns a project containing the good crate. Unit tests cover the assess_discovery decision.

Written with Claude, but I believe I understand what is going on.

`discover_bazel_rust_project` builds the rust-analyzer aspect over the
whole workspace and bailed on any non-zero Bazel exit. In a large
monorepo a single broken target (e.g. an unrelated, unmaintained one)
aborted the build, leaving rust-analyzer with no Bazel project model. It
then silently falls back to a Cargo workspace, which breaks proc-macro
expansion (toolchain ABI mismatch) and materializes a stray `target/`.

Pass `--keep_going` so Bazel keeps building the rest of the graph, and
treat the result as usable when the BEP still yielded crate specs:
proceed with a `log::warn` that the project may be incomplete, and only
fail when zero specs were produced. This mirrors `flycheck`'s existing
exit-code handling.

Add an end-to-end test that stands up a workspace with one good
`rust_library` and one target that fails analysis, then checks discovery
still returns a project containing the good crate. Unit tests cover the
`assess_discovery` decision.

@UebelAndre UebelAndre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Seems reasonable to me 😄

@UebelAndre UebelAndre added this pull request to the merge queue Jul 3, 2026
Merged via the queue into bazelbuild:main with commit 4c2c460 Jul 3, 2026
3 checks passed
@mgeisler

mgeisler commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks a lot, and thanks for your great changes to make rust-analyzer easy to use!

github-merge-queue Bot pushed a commit that referenced this pull request Jul 5, 2026
These were not triggered before the PR was merged. I’m not sure why more
tests are run on `main` than on PRs, but maybe this could be revisited
to at least gate PRs on this kind of thing?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants