Skip to content

Commit d1bc9ce

Browse files
committed
Ignore errors in Drop for unix::fs::Dir
Fixes rust-lang#124105
1 parent becebb3 commit d1bc9ce

File tree

1 file changed

+3
-6
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+3
-6
lines changed

library/std/src/sys/pal/unix/fs.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -870,12 +870,9 @@ impl Iterator for ReadDir {
870870

871871
impl Drop for Dir {
872872
fn drop(&mut self) {
873-
let r = unsafe { libc::closedir(self.0) };
874-
assert!(
875-
r == 0 || crate::io::Error::last_os_error().is_interrupted(),
876-
"unexpected error during closedir: {:?}",
877-
crate::io::Error::last_os_error()
878-
);
873+
// Note that errors are ignored when closing a directory as we have
874+
// no non-destructive way to report it. See #124105 and #98338.
875+
let _ = unsafe { libc::closedir(self.0) };
879876
}
880877
}
881878

0 commit comments

Comments
 (0)