Skip to content

Commit 083e013

Browse files
Rollup merge of rust-lang#34019 - kennytm:fix-33958, r=steveklabnik
Restore original meaning of std::fs::read_dir's example changed in rust-lang#33958 `DirEntry.file_type().is_dir()` will not follow symlinks, but the original example (`fs::metadata(&path).is_dir()`) does. Therefore the change in rust-lang#33958 introduced a subtle difference that now it won't enter linked folders. To preserve the same behavior, we use `Path::is_dir()` instead, which does follow symlink. (See discussion in the previous PR for detail.)
2 parents 320e27d + 1d7f345 commit 083e013

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libstd/fs.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1343,8 +1343,9 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
13431343
/// if dir.is_dir() {
13441344
/// for entry in try!(fs::read_dir(dir)) {
13451345
/// let entry = try!(entry);
1346-
/// if try!(entry.file_type()).is_dir() {
1347-
/// try!(visit_dirs(&entry.path(), cb));
1346+
/// let path = entry.path();
1347+
/// if path.is_dir() {
1348+
/// try!(visit_dirs(&path, cb));
13481349
/// } else {
13491350
/// cb(&entry);
13501351
/// }

0 commit comments

Comments
 (0)