From fa0d962ea8bbcd2e0153a1010aeba4d008e5a086 Mon Sep 17 00:00:00 2001 From: Chen Yuheng Date: Tue, 22 Apr 2025 14:52:06 +0800 Subject: [PATCH] rust_analyzer: follow symlink --- tools/rust_analyzer/rust_project.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/rust_analyzer/rust_project.rs b/tools/rust_analyzer/rust_project.rs index 749347ea33..d3620dc0c9 100644 --- a/tools/rust_analyzer/rust_project.rs +++ b/tools/rust_analyzer/rust_project.rs @@ -252,6 +252,11 @@ pub enum RunnableKind { TestOne, } +fn try_symlink(f: &String) -> String { + std::fs::read_link(f).map(|v| v.to_string_lossy().to_string()) + .unwrap_or(f.clone()) +} + pub fn assemble_rust_project( bazel: &Utf8Path, workspace: &Utf8Path, @@ -337,7 +342,7 @@ pub fn assemble_rust_project( project.crates.push(Crate { display_name: Some(c.display_name.clone()), - root_module: c.root_module.clone(), + root_module: try_symlink(&c.root_module), edition: c.edition.clone(), deps: c .deps