Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions library/core/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

use crate::fmt;

/// The type of raw OS error codes.
///
/// This is an [`i32`] on all currently supported platforms, but platforms
/// added in the future (such as UEFI) may use a different primitive type like
/// [`usize`]. Use `as` or [`into`] conversions where applicable to ensure maximum
/// portability.
///
/// [`into`]: Into::into
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
pub type RawOsError = cfg_select! {
target_os = "uefi" => usize,
_ => i32,
};

/// A list specifying general categories of I/O error.
///
/// This list is intended to grow over time and it is not recommended to
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ mod error;
pub use self::borrowed_buf::{BorrowedBuf, BorrowedCursor};
#[unstable(feature = "core_io", issue = "154046")]
pub use self::error::ErrorKind;
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
pub use self::error::RawOsError;
13 changes: 2 additions & 11 deletions library/std/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ mod tests;

#[stable(feature = "rust1", since = "1.0.0")]
pub use core::io::ErrorKind;
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
pub use core::io::RawOsError;

// On 64-bit platforms, `io::Error` may use a bit-packed representation to
// reduce size. However, this representation assumes that error codes are
Expand Down Expand Up @@ -140,17 +142,6 @@ enum ErrorData<C> {
Custom(C),
}

/// The type of raw OS error codes returned by [`Error::raw_os_error`].
///
/// This is an [`i32`] on all currently supported platforms, but platforms
/// added in the future (such as UEFI) may use a different primitive type like
/// [`usize`]. Use `as`or [`into`] conversions where applicable to ensure maximum
/// portability.
///
/// [`into`]: Into::into
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
pub type RawOsError = sys::io::RawOsError;

// `#[repr(align(4))]` is probably redundant, it should have that value or
// higher already. We include it just because repr_bitpacked.rs's encoding
// requires an alignment >= 4 (note that `#[repr(align)]` will not reduce the
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@
#![feature(ptr_as_uninit)]
#![feature(ptr_mask)]
#![feature(random)]
#![feature(raw_os_error_ty)]
#![feature(slice_internals)]
#![feature(slice_ptr_get)]
#![feature(slice_range)]
Expand Down
5 changes: 0 additions & 5 deletions library/std/src/sys/io/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,3 @@ cfg_select! {
pub use generic::*;
}
}

pub type RawOsError = cfg_select! {
target_os = "uefi" => usize,
_ => i32,
};
5 changes: 2 additions & 3 deletions library/std/src/sys/io/error/motor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::io;
use crate::sys::io::RawOsError;

pub fn errno() -> RawOsError {
pub fn errno() -> io::RawOsError {
// Not used in Motor OS because it is ambiguous: Motor OS
// is micro-kernel-based, and I/O happens via a shared-memory
// ring buffer, so an I/O operation that on a unix is a syscall
Expand Down Expand Up @@ -57,7 +56,7 @@ pub fn decode_error_kind(code: io::RawOsError) -> io::ErrorKind {
}
}

pub fn error_string(errno: RawOsError) -> String {
pub fn error_string(errno: io::RawOsError) -> String {
let error: moto_rt::Error = match errno {
x if x < 0 => moto_rt::Error::Unknown,
x if x > u16::MAX.into() => moto_rt::Error::Unknown,
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub use error::errno_location;
target_os = "wasi",
))]
pub use error::set_errno;
pub use error::{RawOsError, decode_error_kind, errno, error_string, is_interrupted};
pub use error::{decode_error_kind, errno, error_string, is_interrupted};
pub use io_slice::{IoSlice, IoSliceMut};
pub use is_terminal::is_terminal;
pub use kernel_copy::{CopyState, kernel_copy};
Expand Down
Loading