From aa73de400ddc4ac9dde1fdba69818bb3f20deb74 Mon Sep 17 00:00:00 2001 From: joboet Date: Fri, 12 Dec 2025 20:28:42 +0100 Subject: [PATCH] std: move `RawOsError` to `sys::io` --- library/std/src/io/error.rs | 2 +- library/std/src/sys/io/mod.rs | 5 +++++ library/std/src/sys/pal/mod.rs | 3 --- library/std/src/sys/pal/uefi/mod.rs | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 0167be4d514c..98b266663ad2 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -139,7 +139,7 @@ enum ErrorData { /// /// [`into`]: Into::into #[unstable(feature = "raw_os_error_ty", issue = "107792")] -pub type RawOsError = sys::RawOsError; +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 diff --git a/library/std/src/sys/io/mod.rs b/library/std/src/sys/io/mod.rs index b4e4e6ec7312..4a5d6f8e27f2 100644 --- a/library/std/src/sys/io/mod.rs +++ b/library/std/src/sys/io/mod.rs @@ -55,3 +55,8 @@ mod is_terminal { // Bare metal platforms usually have very small amounts of RAM // (in the order of hundreds of KB) pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { 8 * 1024 }; + +pub type RawOsError = cfg_select! { + target_os = "uefi" => usize, + _ => i32, +}; diff --git a/library/std/src/sys/pal/mod.rs b/library/std/src/sys/pal/mod.rs index 2bd3ec8188a7..0ecbcf5a2702 100644 --- a/library/std/src/sys/pal/mod.rs +++ b/library/std/src/sys/pal/mod.rs @@ -92,6 +92,3 @@ target_os = "fuchsia" => true, _ => false, }; - -#[cfg(not(target_os = "uefi"))] -pub type RawOsError = i32; diff --git a/library/std/src/sys/pal/uefi/mod.rs b/library/std/src/sys/pal/uefi/mod.rs index e8236437b9c9..61725b2ed048 100644 --- a/library/std/src/sys/pal/uefi/mod.rs +++ b/library/std/src/sys/pal/uefi/mod.rs @@ -13,6 +13,8 @@ //! [`OsString`]: crate::ffi::OsString #![forbid(unsafe_op_in_unsafe_fn)] +use crate::io::RawOsError; + pub mod helpers; pub mod os; pub mod time; @@ -20,8 +22,6 @@ #[cfg(test)] mod tests; -pub type RawOsError = usize; - use crate::io as std_io; use crate::os::uefi; use crate::ptr::NonNull;