Skip to content
Draft
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
26 changes: 26 additions & 0 deletions library/core/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

use crate::fmt;

#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
#[doc(hidden)]
pub mod raw_os_error {
#![expect(dead_code)]

use super::{ErrorKind, RawOsError};

#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
#[eii]
pub fn decode_error_kind(_: RawOsError) -> ErrorKind {
ErrorKind::Uncategorized
}

#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
#[eii]
pub fn fmt(errno: RawOsError, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
<ErrorKind as core::fmt::Display>::fmt(&decode_error_kind(errno), fmt)
}

#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
#[eii]
pub fn is_interrupted(errno: RawOsError) -> bool {
matches!(decode_error_kind(errno), ErrorKind::Interrupted)
}
}

/// The type of raw OS error codes.
///
/// This is an [`i32`] on all currently supported platforms, but platforms
Expand Down
3 changes: 3 additions & 0 deletions library/core/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ pub use self::cursor::Cursor;
pub use self::error::ErrorKind;
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
pub use self::error::RawOsError;
#[doc(hidden)]
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
pub use self::error::raw_os_error;
#[unstable(feature = "core_io", issue = "154046")]
pub use self::io_slice::{IoSlice, IoSliceMut};
#[unstable(feature = "core_io", issue = "154046")]
Expand Down
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
#![feature(diagnostic_on_unmatched_args)]
#![feature(doc_cfg)]
#![feature(doc_notable_trait)]
#![feature(extern_item_impls)]
#![feature(extern_types)]
#![feature(f16)]
#![feature(f128)]
Expand Down
18 changes: 18 additions & 0 deletions library/std/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ pub use core::io::ErrorKind;
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
pub use core::io::RawOsError;

#[cfg(not(test))]
#[core::io::raw_os_error::decode_error_kind]
fn raw_os_error_decode(code: RawOsError) -> ErrorKind {
Comment thread
bushrat011899 marked this conversation as resolved.
sys::io::decode_error_kind(code)
}

#[cfg(not(test))]
#[core::io::raw_os_error::fmt]
fn raw_os_error_fmt(code: RawOsError, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.write_str(&sys::io::error_string(code))
}

#[cfg(not(test))]
#[core::io::raw_os_error::is_interrupted]
fn raw_os_error_is_interrupted(code: RawOsError) -> bool {
sys::io::is_interrupted(code)
}

// On 64-bit platforms, `io::Error` may use a bit-packed representation to
// reduce size. However, this representation assumes that error codes are
// always 32-bit wide.
Expand Down
24 changes: 12 additions & 12 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pr:
<<: *job-linux-4c
- name: x86_64-gnu-llvm-21
env:
ENABLE_GCC_CODEGEN: "1"
# ENABLE_GCC_CODEGEN: "1"
DOCKER_SCRIPT: x86_64-gnu-llvm.sh
<<: *job-linux-4c
- name: aarch64-gnu-llvm-21-1
Expand All @@ -146,17 +146,17 @@ pr:
<<: *job-linux-4c
- name: x86_64-gnu-miri
<<: *job-linux-4c
- name: x86_64-gnu-gcc
doc_url: https://rustc-dev-guide.rust-lang.org/tests/codegen-backend-tests/cg_gcc.html
env:
CODEGEN_BACKENDS: llvm,gcc
<<: *job-linux-4c
- name: x86_64-gnu-gcc-core-tests
doc_url: https://rustc-dev-guide.rust-lang.org/tests/codegen-backend-tests/cg_gcc.html
env:
CODEGEN_BACKENDS: gcc
<<: *job-linux-4c
# - name: x86_64-gnu-gcc
# doc_url: https://rustc-dev-guide.rust-lang.org/tests/codegen-backend-tests/cg_gcc.html
# env:
# CODEGEN_BACKENDS: llvm,gcc
# <<: *job-linux-4c
# - name: x86_64-gnu-gcc-core-tests
# doc_url: https://rustc-dev-guide.rust-lang.org/tests/codegen-backend-tests/cg_gcc.html
# env:
# CODEGEN_BACKENDS: gcc
# <<: *job-linux-4c

# This job tests features we want to stabilize soon, to ensure they don't
# regress.
- name: x86_64-gnu-pre-stabilization
Expand Down
20 changes: 20 additions & 0 deletions tests/ui/eii/io_in_core_no_std.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! Check that dynamic libraries can link and run now that there is an unconditional use
//! of EII in `core`.

//@ build-pass
//@ compile-flags: -Cpanic=abort
//@ no-prefer-dynamic
//@ needs-crate-type: dylib
#![crate_type = "dylib"]
#![feature(core_io_internals)]
#![feature(core_io)]
#![feature(raw_os_error_ty)]
#![no_std]
#![no_implicit_prelude]

#[panic_handler]
fn panic_handler(_info: &core::panic::PanicInfo<'_>) -> ! {
loop {}
}

pub use core::io::raw_os_error::*;
17 changes: 17 additions & 0 deletions tests/ui/eii/io_in_core_with_std.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! Check that `no_std` dynamic libraries can link and run without depending on `libstd`
//! now that there is an unconditional use of EII in `core`.
//@ build-pass
//@ compile-flags: -Cpanic=abort
//@ no-prefer-dynamic
//@ needs-crate-type: dylib
#![crate_type = "dylib"]
#![feature(core_io_internals)]
#![feature(core_io)]
#![feature(raw_os_error_ty)]
#![no_std]
#![no_implicit_prelude]

extern crate std;

pub use core::io::raw_os_error::*;
32 changes: 0 additions & 32 deletions tests/ui/imports/extern-crate-used.rs

@bjorn3 bjorn3 Jun 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They now fail because libcore implements an EII. Crates that implement an EII are never considered unused as removing them would affect which implementation is picked for an EII or even give an error if there ie no default. That check should probably be changed to ignore the default implementation of an EII.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh ok. I'll update this bodge commit to note this an be a bit more surgical than just outright deleting the tests. Thanks!

This file was deleted.

19 changes: 0 additions & 19 deletions tests/ui/imports/extern-crate-used.stderr

This file was deleted.

71 changes: 0 additions & 71 deletions tests/ui/lint/unnecessary-extern-crate.rs

This file was deleted.

73 changes: 0 additions & 73 deletions tests/ui/lint/unnecessary-extern-crate.stderr

This file was deleted.

Loading
Loading