Skip to content

rust_analyzer: fix target exclusions in gen_rust_project#4065

Draft
ptsteadman wants to merge 1 commit into
bazelbuild:mainfrom
ptsteadman:ptsteadman/fix-exclusions-in-target-filter
Draft

rust_analyzer: fix target exclusions in gen_rust_project#4065
ptsteadman wants to merge 1 commit into
bazelbuild:mainfrom
ptsteadman:ptsteadman/fix-exclusions-in-target-filter

Conversation

@ptsteadman
Copy link
Copy Markdown

@ptsteadman ptsteadman commented Jun 2, 2026

gen_rust_project did not support target exclusion patterns (e.g. -//util/process_wrapper/...). Two bugs:

  1. lib.rs: bazel build received exclusion patterns before the end-of-options marker --, so Bazel rejected them as unknown flags.
  2. aquery.rs: the deps() expression was constructed by joining all targets with + (e.g. deps(//util/...+-//util/process_wrapper/...)), which is invalid aquery syntax. Exclusions need to use - instead.

Before (main), fails at bazel build:

$ bazel run @rules_rust//tools/rust_analyzer:gen_rust_project -- -- //util/... -//util/process_wrapper/...
ERROR: Invalid options syntax: -//util/process_wrapper/...
Note: Negative target patterns can only appear after the end of options marker ('--').
Error: bazel build failed: (exit status: 2)

After (this branch), full round-trip succeeds:

$ bazel run @rules_rust//tools/rust_analyzer:gen_rust_project -- -- //util/... -//util/process_wrapper/...
INFO: running bazel build...
INFO: bazel build finished
INFO: running bazel aquery...
INFO: bazel aquery finished; parsing spec files...
# rust-project.json written with action_args, collect_coverage, label, workspace_status
# (process_wrapper excluded as expected)

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Jun 2, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ptsteadman ptsteadman force-pushed the ptsteadman/fix-exclusions-in-target-filter branch from bf0e5b8 to ef10a69 Compare June 2, 2026 20:59
Signed-off-by: Patrick Steadman <ptsteadman@gmail.com>
@ptsteadman ptsteadman force-pushed the ptsteadman/fix-exclusions-in-target-filter branch from ef10a69 to 1a5097d Compare June 2, 2026 21:17
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.

1 participant