@@ -94,7 +94,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
9494 fn check_windows_verbatim ( _: & Path ) -> bool { false }
9595
9696 // calculate root this way to handle volume-relative Windows paths correctly
97- let mut root = os:: getcwd ( ) ;
97+ let mut root = os:: getcwd ( ) . unwrap ( ) ;
9898 let pat_root = Path :: new ( pattern) . root_path ( ) ;
9999 if pat_root. is_some ( ) {
100100 if check_windows_verbatim ( pat_root. as_ref ( ) . unwrap ( ) ) {
@@ -375,25 +375,24 @@ impl Pattern {
375375 m => return m,
376376 }
377377
378- if file. is_empty ( ) {
379- return EntirePatternDoesntMatch ;
380- }
378+ let ( c, next) = match file. slice_shift_char ( ) {
379+ None => return EntirePatternDoesntMatch ,
380+ Some ( pair) => pair
381+ } ;
381382
382- let ( some_c, next) = file. slice_shift_char ( ) ;
383- if require_literal ( some_c. unwrap ( ) ) {
383+ if require_literal ( c) {
384384 return SubPatternDoesntMatch ;
385385 }
386- prev_char. set ( some_c ) ;
386+ prev_char. set ( Some ( c ) ) ;
387387 file = next;
388388 }
389389 }
390390 _ => {
391- if file. is_empty ( ) {
392- return EntirePatternDoesntMatch ;
393- }
391+ let ( c, next) = match file. slice_shift_char ( ) {
392+ None => return EntirePatternDoesntMatch ,
393+ Some ( pair) => pair
394+ } ;
394395
395- let ( some_c, next) = file. slice_shift_char ( ) ;
396- let c = some_c. unwrap ( ) ;
397396 let matches = match * token {
398397 AnyChar => {
399398 !require_literal ( c)
@@ -420,7 +419,7 @@ impl Pattern {
420419 if !matches {
421420 return SubPatternDoesntMatch ;
422421 }
423- prev_char. set ( some_c ) ;
422+ prev_char. set ( Some ( c ) ) ;
424423 file = next;
425424 }
426425 }
@@ -626,7 +625,7 @@ mod test {
626625 assert ! ( glob( "//" ) . next( ) . is_some( ) ) ;
627626
628627 // check windows absolute paths with host/device components
629- let root_with_device = os:: getcwd ( ) . root_path ( ) . unwrap ( ) . join ( "*" ) ;
628+ let root_with_device = os:: getcwd ( ) . unwrap ( ) . root_path ( ) . unwrap ( ) . join ( "*" ) ;
630629 // FIXME (#9639): This needs to handle non-utf8 paths
631630 assert ! ( glob( root_with_device. as_str( ) . unwrap( ) ) . next( ) . is_some( ) ) ;
632631 }
0 commit comments