Rust-analyzer diagnostic paths show `./src/xxx` instead of `src/xxx`, breaking VSCode navigation
⚓ Rust 📅 2025-05-30 👤 surdeus 👁️ 12Problem Description
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.
Minimal Reproduction
// src/main.rs
fn error() -> Result<(), ()> {
Err(())
}
fn main() {
error().unwrap();
}
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.
{
"rust-analyzer.diagnostics.remapPrefix": {
"./": ""
}
}
Questions
Are there other VSCode settings that might affect diagnostic path formatting? Any insights or alternative solutions would be greatly appreciated!
1 post - 1 participant
🏷️ rust_feed