Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions tools/hermes/src/charon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,7 @@ pub fn run_charon(args: &Args, roots: &Roots, packages: &[HermesArtifact]) -> Re
if let Some(stdout) = child.stdout.take() {
let reader = BufReader::new(stdout);

let mut mapper = crate::diagnostics::DiagnosticMapper::new(
roots.workspace.clone(),
roots.workspace.clone(),
);

let mut mapper = crate::diagnostics::DiagnosticMapper::new(roots.workspace.clone());
for line in reader.lines() {
if let Ok(line) = line {
if let Ok(msg) = serde_json::from_str::<cargo_metadata::Message>(&line) {
Expand Down
10 changes: 2 additions & 8 deletions tools/hermes/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use miette::{NamedSource, Report, SourceOffset};
use thiserror::Error;

pub struct DiagnosticMapper {
shadow_root: PathBuf,
user_root: PathBuf,
user_root_canonical: PathBuf,
source_cache: HashMap<PathBuf, String>,
Expand Down Expand Up @@ -53,10 +52,10 @@ impl miette::Diagnostic for MappedError {
}

impl DiagnosticMapper {
pub fn new(shadow_root: PathBuf, user_root: PathBuf) -> Self {
pub fn new(user_root: PathBuf) -> Self {
let user_root_canonical =
fs::canonicalize(&user_root).unwrap_or_else(|_| user_root.clone());
Self { shadow_root, user_root, user_root_canonical, source_cache: HashMap::new() }
Self { user_root, user_root_canonical, source_cache: HashMap::new() }
}

pub fn map_path(&self, path: &Path) -> Option<PathBuf> {
Expand All @@ -65,11 +64,6 @@ impl DiagnosticMapper {
p = self.user_root.join(p);
}

// Strategy A: Starts with shadow_root
if let Ok(suffix) = p.strip_prefix(&self.shadow_root) {
return Some(self.user_root.join(suffix));
}

// Strategy B: Starts with user_root or user_root_canonical
if p.starts_with(&self.user_root) || p.starts_with(&self.user_root_canonical) {
return Some(p);
Expand Down
Loading