@@ -605,33 +605,26 @@ impl<'cfg> Workspace<'cfg> {
605605 }
606606 }
607607
608- find_root_iter ( manifest_path, self . config )
609- . find_map ( |ances_manifest_path| {
610- debug ! ( "find_root - trying {}" , ances_manifest_path. display( ) ) ;
611- let manifest = self . packages . load ( & ances_manifest_path) ;
612- match manifest {
613- Ok ( manifest) => match * manifest. workspace_config ( ) {
614- WorkspaceConfig :: Root ( ref ances_root_config) => {
615- debug ! ( "find_root - found a root checking exclusion" ) ;
616- if !ances_root_config. is_excluded ( manifest_path) {
617- debug ! ( "find_root - found!" ) ;
618- Some ( Ok ( ances_manifest_path) )
619- } else {
620- None
621- }
622- }
623- WorkspaceConfig :: Member {
624- root : Some ( ref path_to_root) ,
625- } => {
626- debug ! ( "find_root - found pointer" ) ;
627- Some ( Ok ( read_root_pointer ( & ances_manifest_path, path_to_root) ) )
628- }
629- WorkspaceConfig :: Member { .. } => None ,
630- } ,
631- Err ( e) => Some ( Err ( e) ) ,
608+ for ances_manifest_path in find_root_iter ( manifest_path, self . config ) {
609+ debug ! ( "find_root - trying {}" , ances_manifest_path. display( ) ) ;
610+ match * self . packages . load ( & ances_manifest_path) ?. workspace_config ( ) {
611+ WorkspaceConfig :: Root ( ref ances_root_config) => {
612+ debug ! ( "find_root - found a root checking exclusion" ) ;
613+ if !ances_root_config. is_excluded ( manifest_path) {
614+ debug ! ( "find_root - found!" ) ;
615+ return Ok ( Some ( ances_manifest_path) ) ;
616+ }
632617 }
633- } )
634- . transpose ( )
618+ WorkspaceConfig :: Member {
619+ root : Some ( ref path_to_root) ,
620+ } => {
621+ debug ! ( "find_root - found pointer" ) ;
622+ return Ok ( Some ( read_root_pointer ( & ances_manifest_path, path_to_root) ) ) ;
623+ }
624+ WorkspaceConfig :: Member { .. } => { }
625+ }
626+ }
627+ Ok ( None )
635628 }
636629
637630 /// After the root of a workspace has been located, probes for all members
@@ -1834,32 +1827,26 @@ fn parse_manifest(manifest_path: &Path, config: &Config) -> CargoResult<EitherMa
18341827}
18351828
18361829pub fn find_workspace_root ( manifest_path : & Path , config : & Config ) -> CargoResult < Option < PathBuf > > {
1837- find_root_iter ( manifest_path, config)
1838- . find_map ( |ances_manifest_path| {
1839- let manifest = parse_manifest ( & ances_manifest_path, config) ;
1840- match manifest {
1841- Ok ( manifest) => match * manifest. workspace_config ( ) {
1842- WorkspaceConfig :: Root ( ref ances_root_config) => {
1843- debug ! ( "find_root - found a root checking exclusion" ) ;
1844- if !ances_root_config. is_excluded ( manifest_path) {
1845- debug ! ( "find_root - found!" ) ;
1846- Some ( Ok ( ances_manifest_path) )
1847- } else {
1848- None
1849- }
1850- }
1851- WorkspaceConfig :: Member {
1852- root : Some ( ref path_to_root) ,
1853- } => {
1854- debug ! ( "find_root - found pointer" ) ;
1855- Some ( Ok ( read_root_pointer ( & ances_manifest_path, path_to_root) ) )
1856- }
1857- WorkspaceConfig :: Member { .. } => None ,
1858- } ,
1859- Err ( e) => Some ( Err ( e) ) ,
1830+ for ances_manifest_path in find_root_iter ( manifest_path, config) {
1831+ debug ! ( "find_root - trying {}" , ances_manifest_path. display( ) ) ;
1832+ match * parse_manifest ( & ances_manifest_path, config) ?. workspace_config ( ) {
1833+ WorkspaceConfig :: Root ( ref ances_root_config) => {
1834+ debug ! ( "find_root - found a root checking exclusion" ) ;
1835+ if !ances_root_config. is_excluded ( manifest_path) {
1836+ debug ! ( "find_root - found!" ) ;
1837+ return Ok ( Some ( ances_manifest_path) ) ;
1838+ }
18601839 }
1861- } )
1862- . transpose ( )
1840+ WorkspaceConfig :: Member {
1841+ root : Some ( ref path_to_root) ,
1842+ } => {
1843+ debug ! ( "find_root - found pointer" ) ;
1844+ return Ok ( Some ( read_root_pointer ( & ances_manifest_path, path_to_root) ) ) ;
1845+ }
1846+ WorkspaceConfig :: Member { .. } => { }
1847+ }
1848+ }
1849+ Ok ( None )
18631850}
18641851
18651852fn read_root_pointer ( member_manifest : & Path , root_link : & str ) -> PathBuf {
@@ -1877,7 +1864,6 @@ fn find_root_iter<'a>(
18771864 config : & ' a Config ,
18781865) -> impl Iterator < Item = PathBuf > + ' a {
18791866 LookBehind :: new ( paths:: ancestors ( manifest_path, None ) . skip ( 2 ) )
1880- . into_iter ( )
18811867 . take_while ( |path| !path. curr . ends_with ( "target/package" ) )
18821868 // Don't walk across `CARGO_HOME` when we're looking for the
18831869 // workspace root. Sometimes a package will be organized with
0 commit comments