@@ -27,13 +27,31 @@ use crate::{CfgOverrides, InvocationStrategy};
2727///
2828/// We use absolute paths here, `cargo metadata` guarantees to always produce
2929/// abs paths.
30- #[ derive( Debug , Clone , Eq , PartialEq ) ]
30+ #[ derive( Debug , Clone ) ]
3131pub struct CargoWorkspace {
3232 packages : Arena < PackageData > ,
3333 targets : Arena < TargetData > ,
3434 workspace_root : AbsPathBuf ,
35+ // Hack, this should be an implmentation detail, however,
36+ // sometimes it's useful to let the client know the project
37+ // structure.
38+ // This property should only be used as JSON
39+ pub origin_metadata : cargo_metadata:: Metadata ,
40+ }
41+
42+ impl PartialEq for CargoWorkspace {
43+ fn eq ( & self , other : & Self ) -> bool {
44+ self . packages == other. packages
45+ && self . targets == other. targets
46+ && self . workspace_root == other. workspace_root
47+ // Do not compare the origin data
48+ // It's only used to be transfer as JSON
49+ // && self.origin_metadata == other.origin_metadata
50+ }
3551}
3652
53+ impl Eq for CargoWorkspace { }
54+
3755impl ops:: Index < Package > for CargoWorkspace {
3856 type Output = PackageData ;
3957 fn index ( & self , index : Package ) -> & PackageData {
@@ -328,9 +346,11 @@ impl CargoWorkspace {
328346 let mut pkg_by_id = FxHashMap :: default ( ) ;
329347 let mut packages = Arena :: default ( ) ;
330348 let mut targets = Arena :: default ( ) ;
331-
349+ // let tmp = Box::new(meta);
332350 let ws_members = & meta. workspace_members ;
333351
352+ let origin_metadata = meta. clone ( ) ;
353+
334354 meta. packages . sort_by ( |a, b| a. id . cmp ( & b. id ) ) ;
335355 for meta_pkg in meta. packages {
336356 let cargo_metadata:: Package {
@@ -411,7 +431,7 @@ impl CargoWorkspace {
411431 let workspace_root =
412432 AbsPathBuf :: assert ( PathBuf :: from ( meta. workspace_root . into_os_string ( ) ) ) ;
413433
414- CargoWorkspace { packages, targets, workspace_root }
434+ CargoWorkspace { packages, targets, workspace_root, origin_metadata }
415435 }
416436
417437 pub fn packages ( & self ) -> impl Iterator < Item = Package > + ExactSizeIterator + ' _ {
0 commit comments