File tree 1 file changed +24
-0
lines changed
compiler/rustc_codegen_gcc
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -421,3 +421,27 @@ name = "windows_x86_64_msvc"
421
421
version = " 0.52.4"
422
422
source = " registry+https://github.com/rust-lang/crates.io-index"
423
423
checksum = " 32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
424
+ fn main() -> Result<(), Box<dyn std::error::Error>> {
425
+ // create a directory, get a FD to it, then unlink the directory but keep the FD
426
+ std::fs::create_dir("tmp_dir")?;
427
+ let dir_fd = rustix::fs::openat(
428
+ rustix::fs::CWD,
429
+ rustix::cstr!("tmp_dir"),
430
+ rustix::fs::OFlags::RDONLY | rustix::fs::OFlags::CLOEXEC,
431
+ rustix::fs::Mode::empty(),
432
+ )?;
433
+ std::fs::remove_dir("tmp_dir")?;
434
+
435
+ // iterator gets stuck in infinite loop and memory explodes
436
+ rustix::fs::Dir::read_from(dir_fd)?
437
+ // the iterator keeps returning `Some(Err(_))`, but never halts by returning `None`
438
+ // therefore if the implementation ignores the error (or otherwise continues
439
+ // after seeing the error instead of breaking), the loop will not halt
440
+ .filter_map(|dirent_maybe_error| dirent_maybe_error.ok())
441
+ .for_each(|dirent| {
442
+ // your happy path
443
+ println!("{dirent:?}");
444
+ });
445
+
446
+ Ok(())
447
+ }
You can’t perform that action at this time.
0 commit comments