@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
55
66use core:: { Package , SourceId , PackageId , EitherManifest } ;
77use util:: { self , Config } ;
8- use util:: errors:: { CargoResult , CargoResultExt } ;
8+ use util:: errors:: { CargoResult , CargoResultExt , CargoError } ;
99use util:: important_paths:: find_project_manifest_exact;
1010use util:: toml:: read_manifest;
1111
@@ -28,6 +28,7 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config)
2828 -> CargoResult < Vec < Package > > {
2929 let mut all_packages = HashMap :: new ( ) ;
3030 let mut visited = HashSet :: < PathBuf > :: new ( ) ;
31+ let mut errors = Vec :: < CargoError > :: new ( ) ;
3132
3233 trace ! ( "looking for root package: {}, source_id={}" , path. display( ) , source_id) ;
3334
@@ -55,13 +56,16 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config)
5556
5657 if has_manifest ( dir) {
5758 read_nested_packages ( dir, & mut all_packages, source_id, config,
58- & mut visited) ?;
59+ & mut visited, & mut errors ) ?;
5960 }
6061 Ok ( true )
6162 } ) ?;
6263
6364 if all_packages. is_empty ( ) {
64- Err ( format ! ( "Could not find Cargo.toml in `{}`" , path. display( ) ) . into ( ) )
65+ match errors. pop ( ) {
66+ Some ( err) => Err ( err) ,
67+ None => Err ( format ! ( "Could not find Cargo.toml in `{}`" , path. display( ) ) . into ( ) ) ,
68+ }
6569 } else {
6670 Ok ( all_packages. into_iter ( ) . map ( |( _, v) | v) . collect ( ) )
6771 }
@@ -104,13 +108,14 @@ fn read_nested_packages(path: &Path,
104108 all_packages : & mut HashMap < PackageId , Package > ,
105109 source_id : & SourceId ,
106110 config : & Config ,
107- visited : & mut HashSet < PathBuf > ) -> CargoResult < ( ) > {
111+ visited : & mut HashSet < PathBuf > ,
112+ errors : & mut Vec < CargoError > ) -> CargoResult < ( ) > {
108113 if !visited. insert ( path. to_path_buf ( ) ) { return Ok ( ( ) ) }
109114
110115 let manifest_path = find_project_manifest_exact ( path, "Cargo.toml" ) ?;
111116
112117 let ( manifest, nested) = match read_manifest ( & manifest_path, source_id, config) {
113- Err ( _ ) => {
118+ Err ( err ) => {
114119 // Ignore malformed manifests found on git repositories
115120 //
116121 // git source try to find and read all manifests from the repository
@@ -120,6 +125,7 @@ fn read_nested_packages(path: &Path,
120125 // TODO: Add a way to exclude folders?
121126 info ! ( "skipping malformed package found at `{}`" ,
122127 path. to_string_lossy( ) ) ;
128+ errors. push ( err) ;
123129 return Ok ( ( ) ) ;
124130 }
125131 Ok ( tuple) => tuple
@@ -151,7 +157,7 @@ fn read_nested_packages(path: &Path,
151157 for p in nested. iter ( ) {
152158 let path = util:: normalize_path ( & path. join ( p) ) ;
153159 read_nested_packages ( & path, all_packages, source_id,
154- config, visited) ?;
160+ config, visited, errors ) ?;
155161 }
156162 }
157163
0 commit comments