23
23
#![ doc( html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png" ,
24
24
html_favicon_url = "http://www.rust-lang.org/favicon.ico" ,
25
25
html_root_url = "http://doc.rust-lang.org/glob/" ) ]
26
- #![ allow( unstable) ]
27
26
#![ cfg_attr( test, deny( warnings) ) ]
27
+ #![ cfg_attr( test, feature( os) ) ]
28
+ #![ feature( path, io, core, collections, hash, std_misc, unicode) ]
28
29
29
30
use std:: ascii:: AsciiExt ;
30
31
use std:: cell:: Cell ;
@@ -705,7 +706,7 @@ fn fill_todo(todo: &mut Vec<Result<(Path, usize), GlobError>>, patterns: &[Patte
705
706
} ;
706
707
707
708
let pattern = & patterns[ idx] ;
708
-
709
+ let is_dir = path . is_dir ( ) ;
709
710
match pattern_as_str ( pattern) {
710
711
Some ( s) => {
711
712
// This pattern component doesn't have any metacharacters, so we
@@ -715,11 +716,11 @@ fn fill_todo(todo: &mut Vec<Result<(Path, usize), GlobError>>, patterns: &[Patte
715
716
// right away.
716
717
let special = "." == s. as_slice ( ) || ".." == s. as_slice ( ) ;
717
718
let next_path = path. join ( s. as_slice ( ) ) ;
718
- if ( special && path . is_dir ( ) ) || ( !special && next_path. exists ( ) ) {
719
+ if ( special && is_dir) || ( !special && next_path. exists ( ) ) {
719
720
add ( todo, next_path) ;
720
721
}
721
722
} ,
722
- None => {
723
+ None if is_dir => {
723
724
match fs:: readdir ( path) {
724
725
Ok ( mut children) => {
725
726
children. sort_by ( |p1, p2| p2. filename ( ) . cmp ( & p1. filename ( ) ) ) ;
@@ -742,6 +743,7 @@ fn fill_todo(todo: &mut Vec<Result<(Path, usize), GlobError>>, patterns: &[Patte
742
743
} ,
743
744
}
744
745
}
746
+ None => { /* not a directory, nothing more to find */ }
745
747
}
746
748
}
747
749
0 commit comments