|
24 | 24 | html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
25 | 25 | html_root_url = "http://doc.rust-lang.org/glob/")]
|
26 | 26 | #![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)] |
29 | 29 |
|
30 | 30 | use std::ascii::AsciiExt;
|
31 | 31 | use std::cell::Cell;
|
@@ -617,7 +617,7 @@ impl Pattern {
|
617 | 617 |
|
618 | 618 | let prev_char = Cell::new(prev_char);
|
619 | 619 |
|
620 |
| - let require_literal = |&: c| { |
| 620 | + let require_literal = |c| { |
621 | 621 | (options.require_literal_separator && path::is_separator(c)) ||
|
622 | 622 | (options.require_literal_leading_dot && c == '.'
|
623 | 623 | && path::is_separator(prev_char.get().unwrap_or('/')))
|
@@ -715,7 +715,7 @@ fn fill_todo(todo: &mut Vec<Result<(PathBuf, usize), GlobError>>,
|
715 | 715 | return Some(s);
|
716 | 716 | }
|
717 | 717 |
|
718 |
| - let add = |&: todo: &mut Vec<_>, next_path: PathBuf| { |
| 718 | + let add = |todo: &mut Vec<_>, next_path: PathBuf| { |
719 | 719 | if idx + 1 == patterns.len() {
|
720 | 720 | // We know it's good, so don't make the iterator match this path
|
721 | 721 | // against the pattern again. In particular, it can't match
|
@@ -901,7 +901,6 @@ impl MatchOptions {
|
901 | 901 |
|
902 | 902 | #[cfg(test)]
|
903 | 903 | mod test {
|
904 |
| - use std::env; |
905 | 904 | use std::path::Path;
|
906 | 905 | use super::{glob, Pattern, MatchOptions};
|
907 | 906 |
|
@@ -959,10 +958,19 @@ mod test {
|
959 | 958 | assert!(glob("/*").unwrap().next().is_some());
|
960 | 959 | assert!(glob("//").unwrap().next().is_some());
|
961 | 960 |
|
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() |
966 | 974 | }
|
967 | 975 |
|
968 | 976 | #[test]
|
@@ -1173,31 +1181,31 @@ mod test {
|
1173 | 1181 | require_literal_leading_dot: false
|
1174 | 1182 | };
|
1175 | 1183 |
|
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); |
1177 | 1185 | assert!(f(&options_not_require_literal_leading_dot));
|
1178 | 1186 | assert!(!f(&options_require_literal_leading_dot));
|
1179 | 1187 |
|
1180 |
| - let f = |&: options| Pattern::new(".*.*").unwrap().matches_with(".hello.txt", options); |
| 1188 | + let f = |options| Pattern::new(".*.*").unwrap().matches_with(".hello.txt", options); |
1181 | 1189 | assert!(f(&options_not_require_literal_leading_dot));
|
1182 | 1190 | assert!(f(&options_require_literal_leading_dot));
|
1183 | 1191 |
|
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); |
1185 | 1193 | assert!(f(&options_not_require_literal_leading_dot));
|
1186 | 1194 | assert!(!f(&options_require_literal_leading_dot));
|
1187 | 1195 |
|
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); |
1189 | 1197 | assert!(f(&options_not_require_literal_leading_dot));
|
1190 | 1198 | assert!(f(&options_require_literal_leading_dot));
|
1191 | 1199 |
|
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); |
1193 | 1201 | assert!(f(&options_not_require_literal_leading_dot));
|
1194 | 1202 | assert!(f(&options_require_literal_leading_dot));
|
1195 | 1203 |
|
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); |
1197 | 1205 | assert!(f(&options_not_require_literal_leading_dot));
|
1198 | 1206 | assert!(!f(&options_require_literal_leading_dot));
|
1199 | 1207 |
|
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); |
1201 | 1209 | assert!(f(&options_not_require_literal_leading_dot));
|
1202 | 1210 | assert!(!f(&options_require_literal_leading_dot));
|
1203 | 1211 | }
|
|
0 commit comments