diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-09-12 20:02:15 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-12 20:02:15 +1000 |
| commit | f40d78f57e0828f81181e2c7ba0dfc347550a139 (patch) | |
| tree | f79f270992aeaae3c18c79254767352166403265 /library | |
| parent | a7a6445659fd73145e0801d83d47a2892220f9c0 (diff) | |
| parent | af5355cc91fb48ed3d1bf31200b4311f801d24a6 (diff) | |
| download | rust-f40d78f57e0828f81181e2c7ba0dfc347550a139.tar.gz rust-f40d78f57e0828f81181e2c7ba0dfc347550a139.zip | |
Rollup merge of #146432 - hermit-os:hermit-take_error, r=joboet
Implement `Socket::take_error` for Hermit This PR fixes an unused-imports compilation error introduced in 845311a065a5638c516ed96c73b09862b176b329 and implements `Socket::take_error` for Hermit. Hermit's `Socket::take_error` implementation works exactly like the one for Unix. r? joboet
Diffstat (limited to 'library')
| -rw-r--r-- | library/std/src/sys/net/connection/socket/hermit.rs | 3 | ||||
| -rw-r--r-- | library/std/src/sys/pal/hermit/os.rs | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/library/std/src/sys/net/connection/socket/hermit.rs b/library/std/src/sys/net/connection/socket/hermit.rs index f49821657d9..5200eaa5786 100644 --- a/library/std/src/sys/net/connection/socket/hermit.rs +++ b/library/std/src/sys/net/connection/socket/hermit.rs @@ -304,7 +304,8 @@ impl Socket { } pub fn take_error(&self) -> io::Result<Option<io::Error>> { - unimplemented!() + let raw: c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_ERROR)?; + if raw == 0 { Ok(None) } else { Ok(Some(io::Error::from_raw_os_error(raw as i32))) } } // This is used by sys_common code to abstract over Windows and Unix. diff --git a/library/std/src/sys/pal/hermit/os.rs b/library/std/src/sys/pal/hermit/os.rs index 0fe713a503b..9681964ed9b 100644 --- a/library/std/src/sys/pal/hermit/os.rs +++ b/library/std/src/sys/pal/hermit/os.rs @@ -3,7 +3,7 @@ use crate::ffi::{OsStr, OsString}; use crate::marker::PhantomData; use crate::path::{self, PathBuf}; use crate::sys::unsupported; -use crate::{fmt, io, str}; +use crate::{fmt, io}; pub fn errno() -> i32 { unsafe { hermit_abi::get_errno() } |
