Description
Proposal
Problem statement
io::Error
assumes OS error values always fit into an i32
, but that is not true for all platforms.
Motivation, use-cases
rust-lang/rust#105861 introduces std
support for UEFI applications. There is however a problem with the way native OS errors are handled in std
, as the current API expects error values to fit into an i32
. While this the case for all currently supported platforms, UEFI diverges from the pattern by using an usize
1 as error type. This forces code supporting UEFI to convert the native errors to custom io::Error
s, which does not fit well with the current API and looses information.
Solution sketches
Add a new type alias to std::io
(naming open to bikeshedding):
pub type RawOsError = /* platform error type, `i32` most of the time */;
and use it in place of i32
in io::Error::from_raw_os_error
and io::Error::raw_os_error
. This is a backwards-compatible change on all current platforms, but new code wishing to support platforms like UEFI will need to use the new error type to ensure portability.
CC @Ayush1325
Footnotes
-
At least according to the specification. However, error values always have the highest bit set, so
isize
would be more convenient... ↩