about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-10-22 08:09:40 +0000
committerbors <bors@rust-lang.org>2023-10-22 08:09:40 +0000
commit724ba7fe9084e607c79e7656ac173eb617d173f5 (patch)
treec9a8ca3d327993fbc543a13856782f1ad6add94c /library/std/src
parent3932c8771819ae5455bf69b5f78b02e3197975eb (diff)
parent77d8a73fa2afb6991d17b797daba7d4e46e91ba5 (diff)
downloadrust-724ba7fe9084e607c79e7656ac173eb617d173f5.tar.gz
rust-724ba7fe9084e607c79e7656ac173eb617d173f5.zip
Auto merge of #117041 - matthiaskrgr:rollup-b18h0ln, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #116985 (Use gdb.ValuePrinter tag class)
 - #116989 (Skip test if Unix sockets are unsupported)
 - #117034 (Don't crash on empty match in the `nonexhaustive_omitted_patterns` lint)
 - #117037 (rustdoc book doc example error)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/fs/tests.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs
index f0c4be2327c..736b495343e 100644
--- a/library/std/src/fs/tests.rs
+++ b/library/std/src/fs/tests.rs
@@ -1717,7 +1717,7 @@ fn windows_unix_socket_exists() {
     let tmp = tmpdir();
     let socket_path = tmp.join("socket");
 
-    // std doesn't current support Unix sockets on Windows so manually create one here.
+    // std doesn't currently support Unix sockets on Windows so manually create one here.
     net::init();
     unsafe {
         let socket = c::WSASocketW(
@@ -1728,7 +1728,16 @@ fn windows_unix_socket_exists() {
             0,
             c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT,
         );
-        assert_ne!(socket, c::INVALID_SOCKET);
+        // AF_UNIX is not supported on earlier versions of Windows,
+        // so skip this test if it's unsupported and we're not in CI.
+        if socket == c::INVALID_SOCKET {
+            let error = c::WSAGetLastError();
+            if env::var_os("CI").is_none() && error == c::WSAEAFNOSUPPORT {
+                return;
+            } else {
+                panic!("Creating AF_UNIX socket failed (OS error {error})");
+            }
+        }
         let mut addr = c::SOCKADDR_UN { sun_family: c::AF_UNIX, sun_path: mem::zeroed() };
         let bytes = socket_path.as_os_str().as_encoded_bytes();
         addr.sun_path[..bytes.len()].copy_from_slice(bytes);