Skip to content

Commit 4c06c57

Browse files
committed
refactor(cargo-util): one generic for each argument
So `path` and `base` are able to accept different types
1 parent d73d2ca commit 4c06c57

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crates/cargo-util/src/paths.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,9 @@ pub fn set_file_time_no_err<P: AsRef<Path>>(path: P, time: FileTime) {
710710
/// This canonicalizes both paths before stripping. This is useful if the
711711
/// paths are obtained in different ways, and one or the other may or may not
712712
/// have been normalized in some way.
713-
pub fn strip_prefix_canonical<P: AsRef<Path>>(
714-
path: P,
715-
base: P,
713+
pub fn strip_prefix_canonical(
714+
path: impl AsRef<Path>,
715+
base: impl AsRef<Path>,
716716
) -> Result<PathBuf, std::path::StripPrefixError> {
717717
// Not all filesystems support canonicalize. Just ignore if it doesn't work.
718718
let safe_canonicalize = |path: &Path| match path.canonicalize() {

src/cargo/ops/cargo_package/vcs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,11 @@ fn dirty_metadata_paths(pkg: &Package, repo: &git2::Repository) -> CargoResult<V
235235
continue;
236236
};
237237
let abs_path = paths::normalize_path(&root.join(path));
238-
if paths::strip_prefix_canonical(abs_path.as_path(), root).is_ok() {
238+
if paths::strip_prefix_canonical(&abs_path, root).is_ok() {
239239
// Inside package root. Don't bother checking git status.
240240
continue;
241241
}
242-
if let Ok(rel_path) = paths::strip_prefix_canonical(abs_path.as_path(), workdir) {
242+
if let Ok(rel_path) = paths::strip_prefix_canonical(&abs_path, workdir) {
243243
// Outside package root but under git workdir,
244244
if repo.status_file(&rel_path)? != git2::Status::CURRENT {
245245
dirty_files.push(if abs_path.is_symlink() {

0 commit comments

Comments
 (0)