File tree Expand file tree Collapse file tree 7 files changed +33
-1
lines changed Expand file tree Collapse file tree 7 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use semver::ReqParseError;
44use  semver:: VersionReq ; 
55use  serde:: ser; 
66use  serde:: Serialize ; 
7+ use  std:: path:: PathBuf ; 
78use  std:: rc:: Rc ; 
89
910use  crate :: core:: { PackageId ,  SourceId ,  Summary } ; 
@@ -61,6 +62,10 @@ struct SerializedDependency<'a> {
6162    /// The registry URL this dependency is from. 
6263     /// If None, then it comes from the default registry (crates.io). 
6364     registry :  Option < & ' a  str > , 
65+ 
66+     /// The file system path for a local path dependency. 
67+      #[ serde( skip_serializing_if = "Option::is_none" ) ]  
68+     path :  Option < PathBuf > , 
6469} 
6570
6671impl  ser:: Serialize  for  Dependency  { 
@@ -80,6 +85,7 @@ impl ser::Serialize for Dependency {
8085            target :  self . platform ( ) , 
8186            rename :  self . explicit_name_in_toml ( ) . map ( |s| s. as_str ( ) ) , 
8287            registry :  registry_id. as_ref ( ) . map ( |sid| sid. url ( ) . as_str ( ) ) , 
88+             path :  self . source_id ( ) . local_path ( ) , 
8389        } 
8490        . serialize ( s) 
8591    } 
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use std::cmp::{self, Ordering};
99use  std:: collections:: HashSet ; 
1010use  std:: fmt:: { self ,  Formatter } ; 
1111use  std:: hash:: { self ,  Hash } ; 
12- use  std:: path:: Path ; 
12+ use  std:: path:: { Path ,   PathBuf } ; 
1313use  std:: ptr; 
1414use  std:: sync:: Mutex ; 
1515use  url:: Url ; 
@@ -237,6 +237,15 @@ impl SourceId {
237237        self . inner . kind  == SourceKind :: Path 
238238    } 
239239
240+     /// Returns the local path if this is a path dependency. 
241+      pub  fn  local_path ( self )  -> Option < PathBuf >  { 
242+         if  self . inner . kind  != SourceKind :: Path  { 
243+             return  None ; 
244+         } 
245+ 
246+         Some ( self . inner . url . to_file_path ( ) . unwrap ( ) ) 
247+     } 
248+ 
240249    /// Returns `true` if this source is from a registry (either local or not). 
241250     pub  fn  is_registry ( self )  -> bool  { 
242251        matches ! ( 
Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ The output has the following format:
8383                       null if not a target dependency. 
8484                    */  
8585                    " target" :  " cfg(windows)"  ,
86+                     /*  The file system path for a local path dependency.
87+                        not present if not a path dependency. 
88+                     */  
89+                     " path" :  " /path/to/dep"  ,
8690                    /*  A string of the URL of the registry this dependency is from.
8791                       If not specified or null, the dependency is from the default 
8892                       registry (crates.io). 
Original file line number Diff line number Diff line change @@ -78,6 +78,10 @@ OUTPUT FORMAT
7878                                  null if not a target dependency.
7979                               */
8080                               "target": "cfg(windows)",
81+                                /* The file system path for a local path dependency.
82+                                   not present if not a path dependency.
83+                                */
84+                                "path": "/path/to/dep",
8185                               /* A string of the URL of the registry this dependency is from.
8286                                  If not specified or null, the dependency is from the default
8387                                  registry (crates.io).
Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ The output has the following format:
8383                       null if not a target dependency. 
8484                    */  
8585                    " target" :  " cfg(windows)"  ,
86+                     /*  The file system path for a local path dependency.
87+                        not present if not a path dependency. 
88+                     */  
89+                     " path" :  " /path/to/dep"  ,
8690                    /*  A string of the URL of the registry this dependency is from.
8791                       If not specified or null, the dependency is from the default 
8892                       registry (crates.io). 
Original file line number Diff line number Diff line change @@ -80,6 +80,10 @@ The output has the following format:
8080                       null if not a target dependency.
8181                    */
8282                    "target": "cfg(windows)",
83+                     /* The file system path for a local path dependency.
84+                        not present if not a path dependency.
85+                     */
86+                     "path": "/path/to/dep",
8387                    /* A string of the URL of the registry this dependency is from.
8488                       If not specified or null, the dependency is from the default
8589                       registry (crates.io).
Original file line number Diff line number Diff line change @@ -1986,6 +1986,7 @@ fn deps_with_bin_only() {
19861986                      "rename": null, 
19871987                      "optional": false, 
19881988                      "uses_default_features": true, 
1989+                       "path": "[..]/foo/bdep", 
19891990                      "features": [], 
19901991                      "target": null, 
19911992                      "registry": null 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments