fannheyward / coc-rust-analyzer

rust-analyzer extension for coc.nvim
MIT License
1.13k stars 39 forks source link

Errors and warnings after syntax checks are not shown in vim buffers and coc-diagnostics #1123

Closed stavenko closed 1 year ago

stavenko commented 1 year ago

What's the output of :CocInfo

versions

vim version: NVIM v0.8.3 node version: v19.2.0 coc.nvim version: 0.0.82-b7375d5f 2023-01-30 05:09:03 +0800 coc.nvim directory: /Users/vgstav10/.vim/plugged/coc.nvim term: iTerm.app platform: darwin

Log of coc.nvim

2023-03-09T11:59:01.424 WARN (pid:49600) [workspace] - Extension "coc-lists" registered synchronized autocmd "VimLeavePre", which could be slow. 2023-03-09T11:59:01.458 INFO (pid:49600) [plugin] - coc.nvim initialized with node: v19.2.0 after 111 2023-03-09T11:59:01.463 WARN (pid:49600) [workspace] - workspace.createStatusBarItem is deprecated, please use window.createStatusBarItem instead. at t.initStatusBar (/Users/vgstav10/.config/coc/extensions/node_modules/coc-spell-checker/out/index.js:1:156009) at t.activate (/Users/vgstav10/.config/coc/extensions/node_modules/coc-spell-checker/out/index.js:1:23162) 2023-03-09T11:59:01.465 INFO (pid:49600) [language-client-index] - Language server "cSpell" started with 49602 2023-03-09T11:59:02.462 INFO (pid:49600) [attach] - receive notification: doAutocmd [ 2 ] 2023-03-09T11:59:05.319 INFO (pid:49600) [attach] - receive notification: doAutocmd [ 2 ] 2023-03-09T11:59:05.351 INFO (pid:49600) [services] - LanguageClient Rust Analyzer Language Server state change: stopped => starting 2023-03-09T11:59:05.354 INFO (pid:49600) [language-client-index] - Language server "rust-analyzer" started with 49679 2023-03-09T11:59:05.358 INFO (pid:49600) [services] - LanguageClient Rust Analyzer Language Server state change: starting => running 2023-03-09T11:59:05.381 INFO (pid:49600) [services] - service rust-analyzer started 2023-03-09T11:59:11.045 INFO (pid:49600) [attach] - receive notification: showInfo []

What's the output of :CocCommand rust-analyzer.serverVersion rust-analyzer 0.4.1428-standalone (ecc32c2f8 2023-03-07)

What's your coc-rust-analyzer version? You can get it from :CocList extensions 0.72.1

Issue description

coc-rust-analizer fails to report errors in workspaces with dependencies errors.

How to reproduce

  1. Clone repo: https://github.com/stavenko/faulty-coc-rust-ananilzer
  2. Open file `./two/src/main.rs'

Expected: Function do_cmp shown as incorrect, because lifetime specifiers unspecified. This is common rust lifetime error.

Actual: Error is not reported and cannot be seen in buffer

One more possible check:

  1. Clone repo: https://github.com/stavenko/faulty-coc-rust-ananilzer
  2. Go to project root
  3. run command cargo run -p two.

Expected and Actual: Compilation error:

error[E0106]: missing lifetime specifier
 --> two/src/main.rs:1:32
  |
1 | fn do_cmp(a: &str, b: &str) -> &str {
  |              ----     ----     ^ expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b`
help: consider introducing a named lifetime parameter
  |
1 | fn do_cmp<'a>(a: &'a str, b: &'a str) -> &'a str {
  |          ++++     ++          ++          ++

Possible reason:

if you run command cargo check from workspace root, you will see some errors in dependencies. once you fix this errors (just make heed dependency same for both projects in workspace), coc-rust-analyzer works as expected and errors in nvim displayed correctly.

fannheyward commented 1 year ago

rust-analyzer's issue, coc is a LSP client, the diagnostics are came from rust-analyzer. Tested with VSCode + rust-analyzer, same results.