Skip to content

Commit 6b74183

Browse files
committed
Improve error handling when PathSource is relative
When editing dependencies with cargo, if a relative PathSource is supplied cargo panics with "both paths are absolute". This is the opposite of what's actually wrong leading to confusion. This commit changes the error message to say what is actually wrong.
1 parent 9bda880 commit 6b74183

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/cargo/util/toml_mut/dependency.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,8 @@ fn path_field<'a>(
748748
} else {
749749
Cow::Borrowed(crate_root)
750750
};
751-
let relpath = pathdiff::diff_paths(&source.path, relative_to).expect("both paths are absolute");
751+
let relpath = pathdiff::diff_paths(&source.path, relative_to)
752+
.expect("PathSource::path and workspace path must be absolute");
752753
let relpath = relpath.to_str().unwrap().replace('\\', "/");
753754
Ok(relpath)
754755
}

0 commit comments

Comments
 (0)