about summary refs log tree commit diff
path: root/library/std
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-06-20 13:05:06 +0000
committerbors <bors@rust-lang.org>2023-06-20 13:05:06 +0000
commit1b6d4cdc4d923c148198ad4df230af48cdaca59e (patch)
tree66f84e74978aa892eef80da22e393f378d1de027 /library/std
parent6fc0273b5a57eb78cc00841181113fda3e509478 (diff)
parent2368fa27d1e59779fbf4918dbf02778d003da0fa (diff)
downloadrust-1b6d4cdc4d923c148198ad4df230af48cdaca59e.tar.gz
rust-1b6d4cdc4d923c148198ad4df230af48cdaca59e.zip
Auto merge of #112839 - GuillaumeGomez:rollup-jc5nqug, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #112464 (Fix windows `Socket::connect_timeout` overflow)
 - #112720 (Rustdoc: search: color item type and reduce size to avoid clashing)
 - #112762 (Sort the errors from arguments checking so that suggestions are handled properly)
 - #112786 (change binders from tuple structs to named fields)
 - #112794 (Fix linker failures when #[global_allocator] is used in a dependency)
 - #112819 (Disable feature(unboxed_closures, fn_traits) in weird-exprs)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/std')
-rw-r--r--library/std/src/net/tcp/tests.rs11
-rw-r--r--library/std/src/sys/windows/net.rs2
2 files changed, 12 insertions, 1 deletions
diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs
index 7a3c66e4504..db367cfa0f7 100644
--- a/library/std/src/net/tcp/tests.rs
+++ b/library/std/src/net/tcp/tests.rs
@@ -47,6 +47,17 @@ fn connect_error() {
 }
 
 #[test]
+#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
+fn connect_timeout_error() {
+    let socket_addr = next_test_ip4();
+    let result = TcpStream::connect_timeout(&socket_addr, Duration::MAX);
+    assert!(!matches!(result, Err(e) if e.kind() == ErrorKind::TimedOut));
+
+    let _listener = TcpListener::bind(&socket_addr).unwrap();
+    assert!(TcpStream::connect_timeout(&socket_addr, Duration::MAX).is_ok());
+}
+
+#[test]
 fn listen_localhost() {
     let socket_addr = next_test_ip4();
     let listener = t!(TcpListener::bind(&socket_addr));
diff --git a/library/std/src/sys/windows/net.rs b/library/std/src/sys/windows/net.rs
index 2404bbe2b89..1ae42cb7eae 100644
--- a/library/std/src/sys/windows/net.rs
+++ b/library/std/src/sys/windows/net.rs
@@ -159,7 +159,7 @@ impl Socket {
                 }
 
                 let mut timeout = c::timeval {
-                    tv_sec: timeout.as_secs() as c_long,
+                    tv_sec: cmp::min(timeout.as_secs(), c_long::MAX as u64) as c_long,
                     tv_usec: (timeout.subsec_nanos() / 1000) as c_long,
                 };