about summary refs log tree commit diff
path: root/tests/ui/std/fs-nul-byte-paths.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/std/fs-nul-byte-paths.rs')
-rw-r--r--tests/ui/std/fs-nul-byte-paths.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/ui/std/fs-nul-byte-paths.rs b/tests/ui/std/fs-nul-byte-paths.rs
index 5c37980127d..79012362347 100644
--- a/tests/ui/std/fs-nul-byte-paths.rs
+++ b/tests/ui/std/fs-nul-byte-paths.rs
@@ -1,18 +1,22 @@
-//@ run-pass
+//! Test that `std::fs` functions properly reject paths containing NUL bytes.
 
+//@ run-pass
 #![allow(deprecated)]
 //@ ignore-wasm32 no cwd
 //@ ignore-sgx no files
 
-use std::fs;
-use std::io;
+use std::{fs, io};
 
 fn assert_invalid_input<T>(on: &str, result: io::Result<T>) {
     fn inner(on: &str, result: io::Result<()>) {
         match result {
             Ok(()) => panic!("{} didn't return an error on a path with NUL", on),
-            Err(e) => assert!(e.kind() == io::ErrorKind::InvalidInput,
-                              "{} returned a strange {:?} on a path with NUL", on, e.kind()),
+            Err(e) => assert!(
+                e.kind() == io::ErrorKind::InvalidInput,
+                "{} returned a strange {:?} on a path with NUL",
+                on,
+                e.kind()
+            ),
         }
     }
     inner(on, result.map(drop))
@@ -43,6 +47,8 @@ fn main() {
     assert_invalid_input("remove_dir", fs::remove_dir("\0"));
     assert_invalid_input("remove_dir_all", fs::remove_dir_all("\0"));
     assert_invalid_input("read_dir", fs::read_dir("\0"));
-    assert_invalid_input("set_permissions",
-                         fs::set_permissions("\0", fs::metadata(".").unwrap().permissions()));
+    assert_invalid_input(
+        "set_permissions",
+        fs::set_permissions("\0", fs::metadata(".").unwrap().permissions()),
+    );
 }