-
Notifications
You must be signed in to change notification settings - Fork 24
Add type alias for raw OS errors #173
Copy link
Copy link
Closed
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Metadata
Metadata
Assignees
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Type
Fields
Give feedbackNo fields configured for issues without a type.
Proposal
Problem statement
io::Errorassumes OS error values always fit into ani32, but that is not true for all platforms.Motivation, use-cases
rust-lang/rust#105861 introduces
stdsupport for UEFI applications. There is however a problem with the way native OS errors are handled instd, as the current API expects error values to fit into ani32. While this the case for all currently supported platforms, UEFI diverges from the pattern by using anusize1 as error type. This forces code supporting UEFI to convert the native errors to customio::Errors, 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):and use it in place of
i32inio::Error::from_raw_os_errorandio::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
isizewould be more convenient... ↩