Skip to content

Commit

Permalink
Auto merge of #6511 - matklad:metadata-path, r=dwijnand
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
bors committed Jan 2, 2019
2 parents 497f426 + 52810dd commit 4dc7e36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct SerializedPackage<'a> {
dependencies: &'a [Dependency],
targets: Vec<&'a Target>,
features: &'a FeatureMap,
manifest_path: &'a str,
manifest_path: &'a Path,
metadata: Option<&'a toml::Value>,
authors: &'a [String],
categories: &'a [String],
Expand Down Expand Up @@ -113,7 +113,7 @@ impl ser::Serialize for Package {
dependencies: summary.dependencies(),
targets,
features: summary.features(),
manifest_path: &self.manifest_path.display().to_string(),
manifest_path: &self.manifest_path,
metadata: self.manifest.custom_metadata(),
authors,
categories,
Expand Down
13 changes: 7 additions & 6 deletions src/cargo/ops/cargo_output_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::path::PathBuf;

use serde::ser;
use serde::Serialize;
Expand Down Expand Up @@ -41,9 +42,9 @@ fn metadata_no_deps(ws: &Workspace<'_>, _opt: &OutputMetadataOptions) -> CargoRe
packages: ws.members().cloned().collect(),
workspace_members: ws.members().map(|pkg| pkg.package_id()).collect(),
resolve: None,
target_directory: ws.target_dir().display().to_string(),
target_directory: ws.target_dir().clone().into_path_unlocked(),
version: VERSION,
workspace_root: ws.root().display().to_string(),
workspace_root: ws.root().to_path_buf(),
})
}

Expand All @@ -69,9 +70,9 @@ fn metadata_full(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> CargoResult
resolve: (packages, resolve),
root: ws.current_opt().map(|pkg| pkg.package_id()),
}),
target_directory: ws.target_dir().display().to_string(),
target_directory: ws.target_dir().clone().into_path_unlocked(),
version: VERSION,
workspace_root: ws.root().display().to_string(),
workspace_root: ws.root().to_path_buf(),
})
}

Expand All @@ -80,9 +81,9 @@ pub struct ExportInfo {
packages: Vec<Package>,
workspace_members: Vec<PackageId>,
resolve: Option<MetadataResolve>,
target_directory: String,
target_directory: PathBuf,
version: u32,
workspace_root: String,
workspace_root: PathBuf,
}

/// Newtype wrapper to provide a custom `Serialize` implementation.
Expand Down

0 comments on commit 4dc7e36

Please sign in to comment.