@@ -3336,22 +3336,27 @@ impl DirBuilder {
33363336 let mut uncreated_dirs = Vec :: new ( ) ;
33373337 let mut current = path;
33383338
3339- while match self . inner . mkdir ( current) {
3340- Ok ( ( ) ) => false ,
3341- Err ( e) if e. kind ( ) == io:: ErrorKind :: NotFound => true ,
3342- // we check if the err is AlreadyExists for two reasons
3343- // - in case the path exists as a *file*
3344- // - and to avoid calls to .is_dir() in case of other errs
3345- // (i.e. PermissionDenied)
3346- Err ( e) if e. kind ( ) == io:: ErrorKind :: AlreadyExists && current. is_dir ( ) => false ,
3347- Err ( e) => return Err ( e) ,
3348- } && let Some ( parent) = current. parent ( )
3349- {
3350- if parent == Path :: new ( "" ) {
3339+ loop {
3340+ match self . inner . mkdir ( current) {
3341+ Ok ( ( ) ) => break ,
3342+ Err ( e) if e. kind ( ) == io:: ErrorKind :: NotFound => { }
3343+ // we check if the err is AlreadyExists for two reasons
3344+ // - in case the path exists as a *file*
3345+ // - and to avoid calls to .is_dir() in case of other errs
3346+ // (i.e. PermissionDenied)
3347+ Err ( e) if e. kind ( ) == io:: ErrorKind :: AlreadyExists && current. is_dir ( ) => break ,
3348+ Err ( e) => return Err ( e) ,
3349+ }
3350+
3351+ if let Some ( parent) = current. parent ( ) {
3352+ if parent == Path :: new ( "" ) {
3353+ break ;
3354+ }
3355+ uncreated_dirs. push ( current) ;
3356+ current = parent;
3357+ } else {
33513358 break ;
33523359 }
3353- uncreated_dirs. push ( current) ;
3354- current = parent;
33553360 }
33563361
33573362 for uncreated_dir in uncreated_dirs. iter ( ) . rev ( ) {
0 commit comments