I'm experiencing an issue where rust-analyzer reports diagnostic paths in the format ./src/xxx.rs instead of src/xxx.rs. This breaks VSCode's Ctrl+Click navigation functionality, as VSCode only recognizes the latter format for file navigation, in my environment.
Expected: There's a at src/main.rs:xx in the stack backtrace Actual: There's a at ./src/main.rs:xx in the stack backtrace, which can't be clicked to navigate in VSCode
What I've Tried
Verified workspace root contains Cargo.toml
Restarted rust-analyzer server multiple times
Updated rust-analyzer and VSCode to latest versions
Checked various rust-analyzer configuration options
Potential Solution Found
I discovered the rust-analyzer.diagnostics.remapPrefix setting. But it did not work.
What's the message from rust-analyzer? This code should compile without warnings (can't check right now, but there should be no place for error), so it's surprising that this kind of issues can happen at all.
I misstated the issue in my title and have revised the post. The example code crashes at error().unwrap() , displaying the crash location as at ./src/xx in the error output. VSCode can navigate to src/xx format but not ./src/xx format.
Backtraces have nothing to do with rust-analyzer. Backtraces are printed by the standard library, which will try to make the file path relative to the current working directory and use the ./ prefix to indicate that it is indeed a relative path: