rust-lang / rust-lang/rust-analyzer

unresolved-macro-call with rust-project.json generated by bazel+rules_rust

Open
#14,210 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-rust-project C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

rust-analyzer version: 1.69.0-nightly (34e6673a0 2023-02-25)

rustc version: 1.69.0-nightly (34e6673a0 2023-02-25)

target: aarch64-apple-darwin

relevant settings: rust-project.json generated by bazel 6.0.0 and rules_rust v0.18.0.

https://github.com/cloneable/rust-bazel/tree/0ad07fa178d686ea5f1e60854cd27aece6bf263f

See tmp/ dir in repo for the CrateGraph from debug logs and the generated and formatted rust-project.json file.

$ $(rustc +nightly --print sysroot)/bin/rust-analyzer --version
rust-analyzer 1.69.0-nightly (34e6673a 2023-02-25)

$ RA_LOG=rust_analyzer=info $(rustc +nightly --print sysroot)/bin/rust-analyzer diagnostics .
[INFO rust_analyzer::reload] Loaded proc-macros for /private/var/tmp/_bazel_fb/6eced65e9af35df66fe54d4e4c82cece/execroot/rust-bazel/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/crate_index__tokio-macros-1.8.2/libtokio_macros-2565194975.dylib: ["main", "main_rt", "test", "test_rt", "main_fail", "test_fail", "select_priv_declare_output_enum", "select_priv_clean_pattern"]
processing crate: example, module: /Users/fb/Workspaces/rust/rust-bazel/crates/example/src/main.rs
Diagnostic { code: DiagnosticCode("unresolved-macro-call"), message: "unresolved macro `tokio_macros::main`", range: 0..21, severity: Error, unused: false, experimental: true, fixes: None }

diagnostic scan complete

[ERROR rust_analyzer] Unexpected error: diagnostic error detected
diagnostic error detected

I can't figure this one out. The one example binary builds and runs fine with bazel run //crates/example. The rust-project.json file seems to be okay. It contains the absolute path to the proc-macro dylib, which exists at that location. rust-analyzer correctly identifies the tokio::spawn call, but cannot find the main macro. So I directly added tokio-macros as dep, but it still cannot resolve it even though it found the dylib and the contained macros.

Contributor guide

Open the contributing guide

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.

Research direction

Use the linked cloneable/rust-bazel reproduction and inspect its tmp/CrateGraph and generated rust-project.json files. Run the documented rust-analyzer diagnostics command with the Bazel-generated project, then investigate why tokio_macros::main remains unresolved despite the proc-macro dylib being loaded. Done means the example's main macro resolves without the unresolved-macro-call diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.