From 9fb7c5ae5e66703240ce4242f55b66a066e0a93c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 14 Dec 2022 10:01:42 -0500 Subject: [PATCH] fs/tests: Fail fast on duplicate errors rather than looping indefinitely --- library/std/src/fs/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 5c6a16c4bb1..b385ebde439 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -1592,6 +1592,6 @@ fn test_read_dir_infinite_loop() { // Skip the test if we can't open the directory in the first place let Ok(dir) = fs::read_dir(path) else { return }; - // Iterate through the directory - for _ in dir {} + // Check for duplicate errors + assert!(dir.filter(|e| e.is_err()).take(2).count() < 2); }