Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tools/rust_analyzer/bin/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//! decision on the discover/flycheck side.

use std::{
borrow::Cow,
collections::HashMap,
env, fs,
path::{Path, PathBuf},
Expand Down Expand Up @@ -41,10 +42,10 @@ fn logical_name(exe: &Path) -> Option<String> {
fn resolve_target(paths_path: &Path, logical: &str) -> Result<PathBuf, String> {
let raw = fs::read_to_string(paths_path)
.map_err(|e| format!("reading {}: {e}", paths_path.display()))?;
let map: HashMap<&str, &str> =
let map: HashMap<&str, Cow<'_, str>> =
serde_json::from_str(&raw).map_err(|e| format!("parsing {}: {e}", paths_path.display()))?;
map.get(logical)
.map(PathBuf::from)
.map(|c| PathBuf::from(c.as_ref()))
.ok_or_else(|| format!("no entry for `{logical}` in {}", paths_path.display()))
}

Expand Down
Loading