Skip to content

Commit d3fa1c9

Browse files
committed
Merge pull request #9 from gifnksm/master
Update for latest rustc
2 parents 5d7ad1d + 624543c commit d3fa1c9

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/lib.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -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
}

tests/glob-std.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636
}
3737

3838
fn abs_path(path: &str) -> Path {
39-
os::getcwd().join(&Path::new(path))
39+
os::getcwd().unwrap().join(&Path::new(path))
4040
}
4141

4242
fn glob_vec(pattern: &str) -> Vec<Path> {
@@ -45,7 +45,7 @@ fn main() {
4545

4646
let root = TempDir::new("glob-tests");
4747
let root = root.ok().expect("Should have created a temp directory");
48-
assert!(os::change_dir(root.path()));
48+
assert!(os::change_dir(root.path()).is_ok());
4949

5050
mk_file("aaa", true);
5151
mk_file("aaa/apple", true);
@@ -72,8 +72,8 @@ fn main() {
7272
mk_file("xyz/z", false);
7373

7474
assert_eq!(glob_vec(""), Vec::new());
75-
assert_eq!(glob_vec("."), vec!(os::getcwd()));
76-
assert_eq!(glob_vec(".."), vec!(os::getcwd().join("..")));
75+
assert_eq!(glob_vec("."), vec!(os::getcwd().unwrap()));
76+
assert_eq!(glob_vec(".."), vec!(os::getcwd().unwrap().join("..")));
7777

7878
assert_eq!(glob_vec("aaa"), vec!(abs_path("aaa")));
7979
assert_eq!(glob_vec("aaa/"), vec!(abs_path("aaa")));

0 commit comments

Comments
 (0)