@@ -94,7 +94,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
94
94
fn check_windows_verbatim ( _: & Path ) -> bool { false }
95
95
96
96
// calculate root this way to handle volume-relative Windows paths correctly
97
- let mut root = os:: getcwd ( ) ;
97
+ let mut root = os:: getcwd ( ) . unwrap ( ) ;
98
98
let pat_root = Path :: new ( pattern) . root_path ( ) ;
99
99
if pat_root. is_some ( ) {
100
100
if check_windows_verbatim ( pat_root. as_ref ( ) . unwrap ( ) ) {
@@ -375,25 +375,24 @@ impl Pattern {
375
375
m => return m,
376
376
}
377
377
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
+ } ;
381
382
382
- let ( some_c, next) = file. slice_shift_char ( ) ;
383
- if require_literal ( some_c. unwrap ( ) ) {
383
+ if require_literal ( c) {
384
384
return SubPatternDoesntMatch ;
385
385
}
386
- prev_char. set ( some_c ) ;
386
+ prev_char. set ( Some ( c ) ) ;
387
387
file = next;
388
388
}
389
389
}
390
390
_ => {
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
+ } ;
394
395
395
- let ( some_c, next) = file. slice_shift_char ( ) ;
396
- let c = some_c. unwrap ( ) ;
397
396
let matches = match * token {
398
397
AnyChar => {
399
398
!require_literal ( c)
@@ -420,7 +419,7 @@ impl Pattern {
420
419
if !matches {
421
420
return SubPatternDoesntMatch ;
422
421
}
423
- prev_char. set ( some_c ) ;
422
+ prev_char. set ( Some ( c ) ) ;
424
423
file = next;
425
424
}
426
425
}
@@ -626,7 +625,7 @@ mod test {
626
625
assert ! ( glob( "//" ) . next( ) . is_some( ) ) ;
627
626
628
627
// 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 ( "*" ) ;
630
629
// FIXME (#9639): This needs to handle non-utf8 paths
631
630
assert ! ( glob( root_with_device. as_str( ) . unwrap( ) ) . next( ) . is_some( ) ) ;
632
631
}
0 commit comments