Skip to content

Commit 4dc7e36

Browse files
committed
Auto merge of #6511 - matklad:metadata-path, r=dwijnand
use PathBuf in cargo metadata I don't remember why we've used strings in the first place here, but I think that historically there just weren't Serialize impls for `Path`s!
2 parents 497f426 + 52810dd commit 4dc7e36

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/cargo/core/package.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct SerializedPackage<'a> {
6363
dependencies: &'a [Dependency],
6464
targets: Vec<&'a Target>,
6565
features: &'a FeatureMap,
66-
manifest_path: &'a str,
66+
manifest_path: &'a Path,
6767
metadata: Option<&'a toml::Value>,
6868
authors: &'a [String],
6969
categories: &'a [String],
@@ -113,7 +113,7 @@ impl ser::Serialize for Package {
113113
dependencies: summary.dependencies(),
114114
targets,
115115
features: summary.features(),
116-
manifest_path: &self.manifest_path.display().to_string(),
116+
manifest_path: &self.manifest_path,
117117
metadata: self.manifest.custom_metadata(),
118118
authors,
119119
categories,

src/cargo/ops/cargo_output_metadata.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::collections::HashMap;
2+
use std::path::PathBuf;
23

34
use serde::ser;
45
use serde::Serialize;
@@ -41,9 +42,9 @@ fn metadata_no_deps(ws: &Workspace<'_>, _opt: &OutputMetadataOptions) -> CargoRe
4142
packages: ws.members().cloned().collect(),
4243
workspace_members: ws.members().map(|pkg| pkg.package_id()).collect(),
4344
resolve: None,
44-
target_directory: ws.target_dir().display().to_string(),
45+
target_directory: ws.target_dir().clone().into_path_unlocked(),
4546
version: VERSION,
46-
workspace_root: ws.root().display().to_string(),
47+
workspace_root: ws.root().to_path_buf(),
4748
})
4849
}
4950

@@ -69,9 +70,9 @@ fn metadata_full(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> CargoResult
6970
resolve: (packages, resolve),
7071
root: ws.current_opt().map(|pkg| pkg.package_id()),
7172
}),
72-
target_directory: ws.target_dir().display().to_string(),
73+
target_directory: ws.target_dir().clone().into_path_unlocked(),
7374
version: VERSION,
74-
workspace_root: ws.root().display().to_string(),
75+
workspace_root: ws.root().to_path_buf(),
7576
})
7677
}
7778

@@ -80,9 +81,9 @@ pub struct ExportInfo {
8081
packages: Vec<Package>,
8182
workspace_members: Vec<PackageId>,
8283
resolve: Option<MetadataResolve>,
83-
target_directory: String,
84+
target_directory: PathBuf,
8485
version: u32,
85-
workspace_root: String,
86+
workspace_root: PathBuf,
8687
}
8788

8889
/// Newtype wrapper to provide a custom `Serialize` implementation.

0 commit comments

Comments
 (0)