From 624543ccf228e7d63404562d6af2e17bc8d2c3de Mon Sep 17 00:00:00 2001 From: gifnksm Date: Wed, 19 Nov 2014 07:47:53 +0900 Subject: [PATCH] Update for latest rustc --- src/lib.rs | 27 +++++++++++++-------------- tests/glob-std.rs | 8 ++++---- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 65567fe..1462695 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,7 +94,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths { fn check_windows_verbatim(_: &Path) -> bool { false } // calculate root this way to handle volume-relative Windows paths correctly - let mut root = os::getcwd(); + let mut root = os::getcwd().unwrap(); let pat_root = Path::new(pattern).root_path(); if pat_root.is_some() { if check_windows_verbatim(pat_root.as_ref().unwrap()) { @@ -375,25 +375,24 @@ impl Pattern { m => return m, } - if file.is_empty() { - return EntirePatternDoesntMatch; - } + let (c, next) = match file.slice_shift_char() { + None => return EntirePatternDoesntMatch, + Some(pair) => pair + }; - let (some_c, next) = file.slice_shift_char(); - if require_literal(some_c.unwrap()) { + if require_literal(c) { return SubPatternDoesntMatch; } - prev_char.set(some_c); + prev_char.set(Some(c)); file = next; } } _ => { - if file.is_empty() { - return EntirePatternDoesntMatch; - } + let (c, next) = match file.slice_shift_char() { + None => return EntirePatternDoesntMatch, + Some(pair) => pair + }; - let (some_c, next) = file.slice_shift_char(); - let c = some_c.unwrap(); let matches = match *token { AnyChar => { !require_literal(c) @@ -420,7 +419,7 @@ impl Pattern { if !matches { return SubPatternDoesntMatch; } - prev_char.set(some_c); + prev_char.set(Some(c)); file = next; } } @@ -626,7 +625,7 @@ mod test { assert!(glob("//").next().is_some()); // check windows absolute paths with host/device components - let root_with_device = os::getcwd().root_path().unwrap().join("*"); + let root_with_device = os::getcwd().unwrap().root_path().unwrap().join("*"); // FIXME (#9639): This needs to handle non-utf8 paths assert!(glob(root_with_device.as_str().unwrap()).next().is_some()); } diff --git a/tests/glob-std.rs b/tests/glob-std.rs index b95a6d0..c1194ab 100644 --- a/tests/glob-std.rs +++ b/tests/glob-std.rs @@ -36,7 +36,7 @@ fn main() { } fn abs_path(path: &str) -> Path { - os::getcwd().join(&Path::new(path)) + os::getcwd().unwrap().join(&Path::new(path)) } fn glob_vec(pattern: &str) -> Vec { @@ -45,7 +45,7 @@ fn main() { let root = TempDir::new("glob-tests"); let root = root.ok().expect("Should have created a temp directory"); - assert!(os::change_dir(root.path())); + assert!(os::change_dir(root.path()).is_ok()); mk_file("aaa", true); mk_file("aaa/apple", true); @@ -72,8 +72,8 @@ fn main() { mk_file("xyz/z", false); assert_eq!(glob_vec(""), Vec::new()); - assert_eq!(glob_vec("."), vec!(os::getcwd())); - assert_eq!(glob_vec(".."), vec!(os::getcwd().join(".."))); + assert_eq!(glob_vec("."), vec!(os::getcwd().unwrap())); + assert_eq!(glob_vec(".."), vec!(os::getcwd().unwrap().join(".."))); assert_eq!(glob_vec("aaa"), vec!(abs_path("aaa"))); assert_eq!(glob_vec("aaa/"), vec!(abs_path("aaa")));