Skip to content

Commit 8704479

Browse files
committed
Merge pull request #35 from Potpourri/upgrade
Upgrade to latest rust
2 parents bac6273 + 8b0010f commit 8704479

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

src/lib.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2525
html_root_url = "http://doc.rust-lang.org/glob/")]
2626
#![cfg_attr(test, deny(warnings))]
27-
#![cfg_attr(test, feature(env, old_path))]
28-
#![feature(path, io, core, collections, unicode, fs, path, os)]
27+
#![cfg_attr(all(test, windows), feature(std_misc))]
28+
#![feature(path, io, core, collections, unicode, fs, os)]
2929

3030
use std::ascii::AsciiExt;
3131
use std::cell::Cell;
@@ -617,7 +617,7 @@ impl Pattern {
617617

618618
let prev_char = Cell::new(prev_char);
619619

620-
let require_literal = |&: c| {
620+
let require_literal = |c| {
621621
(options.require_literal_separator && path::is_separator(c)) ||
622622
(options.require_literal_leading_dot && c == '.'
623623
&& path::is_separator(prev_char.get().unwrap_or('/')))
@@ -715,7 +715,7 @@ fn fill_todo(todo: &mut Vec<Result<(PathBuf, usize), GlobError>>,
715715
return Some(s);
716716
}
717717

718-
let add = |&: todo: &mut Vec<_>, next_path: PathBuf| {
718+
let add = |todo: &mut Vec<_>, next_path: PathBuf| {
719719
if idx + 1 == patterns.len() {
720720
// We know it's good, so don't make the iterator match this path
721721
// against the pattern again. In particular, it can't match
@@ -901,7 +901,6 @@ impl MatchOptions {
901901

902902
#[cfg(test)]
903903
mod test {
904-
use std::env;
905904
use std::path::Path;
906905
use super::{glob, Pattern, MatchOptions};
907906

@@ -959,10 +958,19 @@ mod test {
959958
assert!(glob("/*").unwrap().next().is_some());
960959
assert!(glob("//").unwrap().next().is_some());
961960

962-
// check windows absolute paths with host/device components
963-
let root_with_device = env::current_dir().unwrap().root_path().unwrap().join("*");
964-
// FIXME (#9639): This needs to handle non-utf8 paths
965-
assert!(glob(root_with_device.as_str().unwrap()).unwrap().next().is_some());
961+
#[cfg(not(windows))] fn win() {}
962+
963+
#[cfg(windows)] fn win() {
964+
use std::env::current_dir;
965+
use std::ffi::AsOsStr;
966+
967+
// check windows absolute paths with host/device components
968+
let root_with_device =
969+
current_dir().ok().and_then(|p| p.prefix().map(|p| p.join("*"))).unwrap();
970+
// FIXME (#9639): This needs to handle non-utf8 paths
971+
assert!(glob(root_with_device.as_os_str().to_str().unwrap()).unwrap().next().is_some());
972+
}
973+
win()
966974
}
967975

968976
#[test]
@@ -1173,31 +1181,31 @@ mod test {
11731181
require_literal_leading_dot: false
11741182
};
11751183

1176-
let f = |&: options| Pattern::new("*.txt").unwrap().matches_with(".hello.txt", options);
1184+
let f = |options| Pattern::new("*.txt").unwrap().matches_with(".hello.txt", options);
11771185
assert!(f(&options_not_require_literal_leading_dot));
11781186
assert!(!f(&options_require_literal_leading_dot));
11791187

1180-
let f = |&: options| Pattern::new(".*.*").unwrap().matches_with(".hello.txt", options);
1188+
let f = |options| Pattern::new(".*.*").unwrap().matches_with(".hello.txt", options);
11811189
assert!(f(&options_not_require_literal_leading_dot));
11821190
assert!(f(&options_require_literal_leading_dot));
11831191

1184-
let f = |&: options| Pattern::new("aaa/bbb/*").unwrap().matches_with("aaa/bbb/.ccc", options);
1192+
let f = |options| Pattern::new("aaa/bbb/*").unwrap().matches_with("aaa/bbb/.ccc", options);
11851193
assert!(f(&options_not_require_literal_leading_dot));
11861194
assert!(!f(&options_require_literal_leading_dot));
11871195

1188-
let f = |&: options| Pattern::new("aaa/bbb/*").unwrap().matches_with("aaa/bbb/c.c.c.", options);
1196+
let f = |options| Pattern::new("aaa/bbb/*").unwrap().matches_with("aaa/bbb/c.c.c.", options);
11891197
assert!(f(&options_not_require_literal_leading_dot));
11901198
assert!(f(&options_require_literal_leading_dot));
11911199

1192-
let f = |&: options| Pattern::new("aaa/bbb/.*").unwrap().matches_with("aaa/bbb/.ccc", options);
1200+
let f = |options| Pattern::new("aaa/bbb/.*").unwrap().matches_with("aaa/bbb/.ccc", options);
11931201
assert!(f(&options_not_require_literal_leading_dot));
11941202
assert!(f(&options_require_literal_leading_dot));
11951203

1196-
let f = |&: options| Pattern::new("aaa/?bbb").unwrap().matches_with("aaa/.bbb", options);
1204+
let f = |options| Pattern::new("aaa/?bbb").unwrap().matches_with("aaa/.bbb", options);
11971205
assert!(f(&options_not_require_literal_leading_dot));
11981206
assert!(!f(&options_require_literal_leading_dot));
11991207

1200-
let f = |&: options| Pattern::new("aaa/[.]bbb").unwrap().matches_with("aaa/.bbb", options);
1208+
let f = |options| Pattern::new("aaa/[.]bbb").unwrap().matches_with("aaa/.bbb", options);
12011209
assert!(f(&options_not_require_literal_leading_dot));
12021210
assert!(!f(&options_require_literal_leading_dot));
12031211
}

tests/glob-std.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// ignore-windows TempDir may cause IoError on windows: #10462
1212

13-
#![feature(old_path, env, old_io, path, fs, io)]
13+
#![feature(old_path, old_io, path, fs, io)]
1414

1515
extern crate glob;
1616

0 commit comments

Comments
 (0)