Hi,

We imported rust-analyzer last week, and right off the bat I've had a user
report that it doesn't work right with proc macros.

src/main.rs:
```
[tokio::main]
async fn main() {
    println!("Hello, world!");
}
```

Cargo.toml:
```
[package]
name = "pmtest"
version = "0.1.0"
edition = "2021"

[dependencies]
tokio = { version = "1.35.1", features = ["rt", "macros", "rt-multi-thread"] }
tokio-macros = "2.2.0"
```

`cargo check` succeeds, but vim's LSP tells me (at line 1):
```
■ proc macro `main` not expanded: cannot find proc-macro server in sysroot 
`/usr/local`
```

Running with `RA_LOG=debug RA_LOG_FILE=ra.log` I don't see much useful in the
log file:

```
...
[DEBUG rust_analyzer::main_loop] Instant { tv_sec: 38661, tv_nsec: 903448618 } 
handle_event(Diagnostics([(FileId(0), [Diagnostic { range: Range { start: 
Position { line: 0, character: 0 }, end: Position { line: 0, character: 14 } }, 
severity: Some(Error), code: Some(String("unresolved-proc-macro")), 
code_description: Some(CodeDescription { href: Url { scheme: "https", 
cannot_be_a_base: false, username: "", password: None, host: 
Some(Domain("rust-analyzer.github.io")), port: None, path: "/manual.html", 
query: None, fragment: Some("unresolved-proc-macro") } }), source: 
Some("rust-analyzer"), message: "proc macro `main` not expanded: cannot find 
proc-macro server in sysroot `/usr/local`", related_information: None, tags: 
None, data: None }])]))
[INFO rust_analyzer::main_loop] task queue len: 2
[DEBUG lsp_server::msg] > 
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///vol/spinner/tmp/src/main.rs","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":14}},"severity":1,"code":"unresolved-proc-macro","codeDescription":{"href":"https://rust-analyzer.github.io/manual.html#unresolved-proc-macro"},"source":"rust-analyzer","message":"proc
 macro `main` not expanded: cannot find proc-macro server in sysroot 
`/usr/local`"}],"version":0}}
...
```

This does not occur when using the LSP with a rustup-installed toolchain on
Linux.

I don't recall seeing this error when I was building RA from source (the magic
command I used to use to build/install was `cargo xtask install --server`).

I notice that in the source code there is a crate called `proc-macro-srv` and
on my linux box there is a binary `rust-analyzer-proc-macro-srv`. Perhaps this
is missing?

I've not had time to look deeper, but wanted to report it here in case someone
already knows the fix.

Cheers

-- 
Best Regards
Edd Barrett

https://www.theunixzoo.co.uk

Reply via email to