Description
Problem
Running cargo check
doesn't give the correct diagnostics when using functions that don't exist in an already built module once rust-analyzer is restarted.
Steps
Example:
fn main() {
}
Then run cargo build
.
Change Rust contents to:
fn main() {
chicken();
}
Write to disk.
(Running cargo check
once file is written to disk will get it to display the correct diagnostics if rust-analyzer is not restarted)
Restart rust-analyzer.
(In vim/neovim, you can run :LspRestart. In VSCode, do ctrl+shift+p (cmd+shift+p on mac), then type "restart" and click on "rust-analyzer: restart server")
Run cargo check
again.
Output will be something like:
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
even though the Rust contents are invalid (unknown function is being called).
Description of cargo check
is:
"The compiler will save metadata files to disk so that future runs will reuse them if the source has not been modified"
Source has been modified and incorrect diagnostics are being given therefore I believe this is a bug. :)
Possible Solution(s)
running cargo clean, use cargo build instead, write file to disk again.
Notes
No response
Version
cargo 1.73.0 (9c4383fb5 2023-08-26)
release: 1.73.0
commit-hash: 9c4383fb55986096b414d98125421ab87b5fd642
commit-date: 2023-08-26
host: aarch64-apple-darwin
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 8.1.2 (sys:0.4.65+curl-8.2.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1u 30 May 2023
os: Mac OS 14.0.0 [64-bit]