Skip to content

Commit 7653e5e

Browse files
committed
Move RawOsError to core::io
1 parent 4cb72b3 commit 7653e5e

6 files changed

Lines changed: 20 additions & 17 deletions

File tree

library/core/src/io/error.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
use crate::fmt;
44

5+
/// The type of raw OS error codes.
6+
///
7+
/// This is an [`i32`] on all currently supported platforms, but platforms
8+
/// added in the future (such as UEFI) may use a different primitive type like
9+
/// [`usize`]. Use `as` or [`into`] conversions where applicable to ensure maximum
10+
/// portability.
11+
///
12+
/// [`into`]: Into::into
13+
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
14+
pub type RawOsError = cfg_select! {
15+
target_os = "uefi" => usize,
16+
_ => i32,
17+
};
18+
519
/// A list specifying general categories of I/O error.
620
///
721
/// This list is intended to grow over time and it is not recommended to

library/core/src/io/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ mod error;
77
pub use self::borrowed_buf::{BorrowedBuf, BorrowedCursor};
88
#[unstable(feature = "core_io", issue = "154046")]
99
pub use self::error::ErrorKind;
10+
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
11+
pub use self::error::RawOsError;

library/std/src/io/error.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ mod tests;
33

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

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

143-
/// The type of raw OS error codes.
144-
///
145-
/// This is an [`i32`] on all currently supported platforms, but platforms
146-
/// added in the future (such as UEFI) may use a different primitive type like
147-
/// [`usize`]. Use `as` or [`into`] conversions where applicable to ensure maximum
148-
/// portability.
149-
///
150-
/// [`into`]: Into::into
151-
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
152-
pub type RawOsError = sys::io::RawOsError;
153-
154145
// `#[repr(align(4))]` is probably redundant, it should have that value or
155146
// higher already. We include it just because repr_bitpacked.rs's encoding
156147
// requires an alignment >= 4 (note that `#[repr(align)]` will not reduce the

library/std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
#![feature(ptr_as_uninit)]
364364
#![feature(ptr_mask)]
365365
#![feature(random)]
366+
#![feature(raw_os_error_ty)]
366367
#![feature(slice_internals)]
367368
#![feature(slice_ptr_get)]
368369
#![feature(slice_range)]

library/std/src/sys/io/error/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,3 @@ cfg_select! {
4848
pub use generic::*;
4949
}
5050
}
51-
52-
pub type RawOsError = cfg_select! {
53-
target_os = "uefi" => usize,
54-
_ => i32,
55-
};

library/std/src/sys/io/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub use error::errno_location;
6262
target_os = "wasi",
6363
))]
6464
pub use error::set_errno;
65-
pub use error::{RawOsError, decode_error_kind, errno, error_string, is_interrupted};
65+
pub use error::{decode_error_kind, errno, error_string, is_interrupted};
6666
pub use io_slice::{IoSlice, IoSliceMut};
6767
pub use is_terminal::is_terminal;
6868
pub use kernel_copy::{CopyState, kernel_copy};

0 commit comments

Comments
 (0)