From 855570b229f1d23e4ed39df9a8d916b7a3943955 Mon Sep 17 00:00:00 2001 From: usamoi Date: Tue, 7 Oct 2025 16:51:16 +0800 Subject: [PATCH 1/2] fix compilation on uefi targets Signed-off-by: usamoi --- rand_core/src/os.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rand_core/src/os.rs b/rand_core/src/os.rs index 49111632d9f..dc4125c9604 100644 --- a/rand_core/src/os.rs +++ b/rand_core/src/os.rs @@ -66,6 +66,14 @@ impl std::error::Error for OsError { } } +// If [`RawOsError`](https://doc.rust-lang.org/std/io/type.RawOsError.html) is stablized, we can use it. + +#[cfg(not(target_os = "uefi"))] +type RawOsError = i32; + +#[cfg(target_os = "uefi")] +type RawOsError = usize; + impl OsError { /// Extract the raw OS error code (if this error came from the OS) /// @@ -75,7 +83,7 @@ impl OsError { /// /// [1]: https://doc.rust-lang.org/std/io/struct.Error.html#method.raw_os_error #[inline] - pub fn raw_os_error(self) -> Option { + pub fn raw_os_error(self) -> Option { self.0.raw_os_error() } } From 23fe09be63dec2cedc24c3d8f77b7e4634f59a2f Mon Sep 17 00:00:00 2001 From: usamoi Date: Wed, 15 Oct 2025 21:04:18 +0800 Subject: [PATCH 2/2] add changelog --- rand_core/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/rand_core/CHANGELOG.md b/rand_core/CHANGELOG.md index a060625114f..ee1b45d0579 100644 --- a/rand_core/CHANGELOG.md +++ b/rand_core/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### API changes - Relax `Sized` bound on impls of `SeedableRng` (#1641) +- Fix `OsError::raw_os_error` on UEFI targets by returning `Option` (#1665) ## [0.9.3] — 2025-02-29 ### Other