about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2025-01-26 06:15:58 +0000
committerChris Denton <chris@chrisdenton.dev>2025-01-26 06:17:12 +0000
commit962ebf0a48436445cf300efc0fa552044f4ca19d (patch)
tree33d315db7accf6e2545beb79bd8550b54ab6db98 /library/std/src/sys
parent50522fad483ad86291db1871b396f9d54f0de6e7 (diff)
downloadrust-962ebf0a48436445cf300efc0fa552044f4ca19d.tar.gz
rust-962ebf0a48436445cf300efc0fa552044f4ca19d.zip
Windows: Test that deleting a running binary fails
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/pal/windows/fs.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/library/std/src/sys/pal/windows/fs.rs b/library/std/src/sys/pal/windows/fs.rs
index 750cf7faeae..bdb55643bb1 100644
--- a/library/std/src/sys/pal/windows/fs.rs
+++ b/library/std/src/sys/pal/windows/fs.rs
@@ -1239,8 +1239,10 @@ pub fn unlink(p: &Path) -> io::Result<()> {
             let mut opts = OpenOptions::new();
             opts.access_mode(c::DELETE);
             opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT);
-            if File::open_native(&p_u16s, &opts).map(|f| f.posix_delete()).is_ok() {
-                return Ok(());
+            if let Ok(f) = File::open_native(&p_u16s, &opts) {
+                if f.posix_delete().is_ok() {
+                    return Ok(());
+                }
             }
         }
         // return the original error if any of the above fails.