fix: canonicalize root path for module inference, fix crate-to-module mapping

This commit is contained in:
2026-06-16 16:40:02 +02:00
parent ae241aacac
commit 100b014ff6
2 changed files with 23 additions and 22 deletions

View File

@@ -20,8 +20,10 @@ impl ModuleName {
root: &Path,
module_mappings: &HashMap<String, String>,
) -> Option<Self> {
let canonical_root = root.canonicalize().unwrap_or_else(|_| root.to_path_buf());
let root_str = canonical_root.to_str().unwrap_or("");
let relative = file_path
.strip_prefix(root.to_str().unwrap_or(""))
.strip_prefix(root_str)
.unwrap_or(file_path)
.trim_start_matches('/');