Fix type error in rust-analyzer rule (#2479)

Before this change, users would fail with the following error:
```
~/Code/rules_rust/examples (main ✔) bazel run @rules_rust//tools/rust_analyzer:gen_rust_project
INFO: Analyzed target @@rules_rust//tools/rust_analyzer:gen_rust_project (51 packages loaded, 2095 targets configured).
INFO: Found 1 target...
Target @@rules_rust//tools/rust_analyzer:gen_rust_project up-to-date:
  bazel-bin/external/rules_rust/tools/rust_analyzer/gen_rust_project
INFO: Elapsed time: 0.530s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/external/rules_rust/tools/rust_analyzer/gen_rust_project
Error: bazel build failed:(exit status: 1)
Computing main repo mapping:
Loading:
Loading: 0 packages loaded
Analyzing: 99 targets (38 packages loaded, 0 targets configured)
Analyzing: 99 targets (38 packages loaded, 0 targets configured)
[0 / 1] [Prepa] BazelWorkspaceStatusAction stable-status.txt
DEBUG: /private/var/tmp/_bazel_user/1426ad6c00f8f7b996ddc75bef70871c/external/rules_rust/bindgen/private/bindgen.bzl:280:14: WARN: rust_bindgen.leak_symbols is set to True for @//bindgen:simple_leaked_bindgen__bindgen - please file an issue at https://github.com/bazelbuild/rules_rust/issues explaining why this was necessary, as this support will be removed soon.
ERROR: /Users/user/Code/rules_rust/examples/bindgen/BUILD.bazel:4:21: in @@rules_rust//rust/private:rust_analyzer.bzl%rust_analyzer_aspect aspect on rust_library rule //bindgen:simple_bindgen:
Traceback (most recent call last):
	File "/private/var/tmp/_bazel_user/1426ad6c00f8f7b996ddc75bef70871c/external/rules_rust/rust/private/rust_analyzer.bzl", line 149, column 51, in _rust_analyzer_aspect_impl
		content = json.encode(_create_single_crate(ctx, rust_analyzer_info)),
	File "/private/var/tmp/_bazel_user/1426ad6c00f8f7b996ddc75bef70871c/external/rules_rust/rust/private/rust_analyzer.bzl", line 233, column 47, in _create_single_crate
		out_dir_path = info.build_info.out_dir.path
Error: 'NoneType' value has no field or method 'path'
ERROR: Analysis of aspects '[@@rules_rust//rust:defs.bzl%rust_analyzer_aspect] with parameters {} on //bindgen:simple_bindgen' failed; build aborted: Analysis of target '//bindgen:simple_bindgen' failed
INFO: Elapsed time: 0.552s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
```
This change fixes this issue.
2 files changed
tree: 7cb240ae6765be2dbb767f7099f4299b87d44b0b
  1. .bazelci/
  2. .bcr/
  3. .github/
  4. bindgen/
  5. cargo/
  6. crate_universe/
  7. docs/
  8. examples/
  9. ffi/
  10. nix/
  11. proto/
  12. rust/
  13. test/
  14. tools/
  15. util/
  16. wasm_bindgen/
  17. .bazelignore
  18. .bazelrc
  19. .clang-format
  20. .envrc
  21. .gitattributes
  22. .gitignore
  23. .prettierrc.toml
  24. .rustfmt.toml
  25. ARCHITECTURE.md
  26. AUTHORS
  27. BUILD.bazel
  28. CODEOWNERS
  29. COMPATIBILITY.md
  30. CONTRIBUTING.md
  31. CONTRIBUTORS
  32. LICENSE.txt
  33. MODULE.bazel
  34. README.md
  35. version.bzl
  36. WORKSPACE.bazel
README.md

Rust Rules

  • Postsubmit Build status

Overview

This repository provides rules for building Rust projects with Bazel.

Community

General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.

Documentation

Please refer to the full documentation.