diff --git a/src/lib.rs b/src/lib.rs index aa9faef..b4a6b89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,7 +70,8 @@ fn rewrite_dep_paths_as_absolute<'a, P: AsRef>( .join(path) .canonicalize() .unwrap() - .to_string_lossy() + .to_str() + .expect("Canonicalized absolute path contained non-UTF-8 segments.") .to_string() }) } @@ -81,9 +82,12 @@ fn rewrite_dep_paths_as_absolute<'a, P: AsRef>( fn rewrite_dep_path_as_relative>(dep: &mut Dependency, parent: P) { if let Dependency::Detailed(detail) = dep { detail.path = detail.path.as_mut().map(|path| { - pathdiff::diff_paths(path, parent.as_ref()) - .unwrap() - .to_string_lossy() + pathdiff::diff_paths(path, parent.as_ref().canonicalize().unwrap()) + .expect( + "Error rewriting dependency path as relative: unable to determine path diff.", + ) + .to_str() + .expect("Error rewriting dependency path as relative: path diff is not UTF-8.") .to_string() }) }