Skip to content

Commit a8208d4

Browse files
authored
Fix type of RawOsError on UEFI targets (#1665)
1 parent d0eef34 commit a8208d4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

rand_core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## Unreleased
88
### API changes
99
- Relax `Sized` bound on impls of `SeedableRng` (#1641)
10+
- Fix `OsError::raw_os_error` on UEFI targets by returning `Option<usize>` (#1665)
1011
- Move `rand_core::impls::*` to `rand_core::le` module (#1667)
1112
- Use Edition 2024 and MSRV 1.85 (#1668)
1213
- Remove fn `TryRngCore::read_adapter(..) -> RngReadAdapter` (replaced with `rand::RngReader`) (#1669)

rand_core/src/os.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ impl std::error::Error for OsError {
6666
}
6767
}
6868

69+
// If [`RawOsError`](https://doc.rust-lang.org/std/io/type.RawOsError.html) is stablized, we can use it.
70+
71+
#[cfg(not(target_os = "uefi"))]
72+
type RawOsError = i32;
73+
74+
#[cfg(target_os = "uefi")]
75+
type RawOsError = usize;
76+
6977
impl OsError {
7078
/// Extract the raw OS error code (if this error came from the OS)
7179
///
@@ -75,7 +83,7 @@ impl OsError {
7583
///
7684
/// [1]: https://doc.rust-lang.org/std/io/struct.Error.html#method.raw_os_error
7785
#[inline]
78-
pub fn raw_os_error(self) -> Option<i32> {
86+
pub fn raw_os_error(self) -> Option<RawOsError> {
7987
self.0.raw_os_error()
8088
}
8189
}

0 commit comments

Comments
 (0)