From f31e4664408f2e0358505ed8403a4d2460aac3e5 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 19 Jun 2026 14:26:29 +1000 Subject: [PATCH 01/10] [Experiment]: Test EII for `RawOsError` in `core` --- library/core/src/io/error.rs | 26 ++++++++++++++++++++++++++ library/core/src/io/mod.rs | 3 +++ library/core/src/lib.rs | 1 + library/std/src/io/error.rs | 15 +++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/library/core/src/io/error.rs b/library/core/src/io/error.rs index 67cd1eebf44f2..5da087e75b5a9 100644 --- a/library/core/src/io/error.rs +++ b/library/core/src/io/error.rs @@ -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(super) fn decode_error_kind(_: RawOsError) -> ErrorKind { + ErrorKind::Uncategorized + } + + #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] + #[eii] + pub(super) fn fmt(errno: RawOsError, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + ::fmt(&decode_error_kind(errno), fmt) + } + + #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] + #[eii] + pub(super) 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 diff --git a/library/core/src/io/mod.rs b/library/core/src/io/mod.rs index 43b6e09bfc4f0..cc9d35e8254e4 100644 --- a/library/core/src/io/mod.rs +++ b/library/core/src/io/mod.rs @@ -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")] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index a26304c46ecea..20cf19eb3dd28 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -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)] diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 360ca83c65a91..86f84ba74ae7e 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -6,6 +6,21 @@ pub use core::io::ErrorKind; #[unstable(feature = "raw_os_error_ty", issue = "107792")] pub use core::io::RawOsError; +#[core::io::raw_os_error::decode_error_kind] +fn raw_os_error_decode(code: RawOsError) -> ErrorKind { + sys::io::decode_error_kind(code) +} + +#[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)) +} + +#[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. From cd28cca97ab7e425b8fa7891a9af47558bb07f9b Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 19 Jun 2026 14:55:40 +1000 Subject: [PATCH 02/10] [Experiment]: Skip GCC jobs; they're not compatible with EII --- src/ci/github-actions/jobs.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 2f92a30065b1f..ddf722c5bde75 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -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 @@ -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 From 7b9c41ed2da1195751fe59fedeae92df27a9aab8 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 19 Jun 2026 15:47:08 +1000 Subject: [PATCH 03/10] [Experiment]: These tests fail somehow? Seem entirely unrelated to me --- tests/ui/imports/extern-crate-used.rs | 32 ------- tests/ui/imports/extern-crate-used.stderr | 19 ----- tests/ui/lint/unnecessary-extern-crate.rs | 71 ---------------- tests/ui/lint/unnecessary-extern-crate.stderr | 73 ---------------- tests/ui/rust-2018/remove-extern-crate.fixed | 51 ----------- tests/ui/rust-2018/remove-extern-crate.rs | 51 ----------- tests/ui/rust-2018/remove-extern-crate.stderr | 44 ---------- .../removing-extern-crate-malformed-cfg.fixed | 16 ---- .../removing-extern-crate-malformed-cfg.rs | 18 ---- ...removing-extern-crate-malformed-cfg.stderr | 84 ------------------- .../ui/rust-2018/removing-extern-crate.fixed | 16 ---- tests/ui/rust-2018/removing-extern-crate.rs | 16 ---- .../ui/rust-2018/removing-extern-crate.stderr | 56 ------------- 13 files changed, 547 deletions(-) delete mode 100644 tests/ui/imports/extern-crate-used.rs delete mode 100644 tests/ui/imports/extern-crate-used.stderr delete mode 100644 tests/ui/lint/unnecessary-extern-crate.rs delete mode 100644 tests/ui/lint/unnecessary-extern-crate.stderr delete mode 100644 tests/ui/rust-2018/remove-extern-crate.fixed delete mode 100644 tests/ui/rust-2018/remove-extern-crate.rs delete mode 100644 tests/ui/rust-2018/remove-extern-crate.stderr delete mode 100644 tests/ui/rust-2018/removing-extern-crate-malformed-cfg.fixed delete mode 100644 tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs delete mode 100644 tests/ui/rust-2018/removing-extern-crate-malformed-cfg.stderr delete mode 100644 tests/ui/rust-2018/removing-extern-crate.fixed delete mode 100644 tests/ui/rust-2018/removing-extern-crate.rs delete mode 100644 tests/ui/rust-2018/removing-extern-crate.stderr diff --git a/tests/ui/imports/extern-crate-used.rs b/tests/ui/imports/extern-crate-used.rs deleted file mode 100644 index b57dd02cd80c7..0000000000000 --- a/tests/ui/imports/extern-crate-used.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Extern crate items are marked as used if they are used -// through extern prelude entries introduced by them. - -//@ edition:2018 - -#![deny(unused_extern_crates)] - -// Shouldn't suggest changing to `use`, as new name -// would no longer be added to the prelude which could cause -// compilation errors for imports that use the new name in -// other modules. See #57672. -extern crate core as iso1; -extern crate core as iso2; -extern crate core as iso3; -extern crate core as iso4; - -// Doesn't introduce its extern prelude entry, so it's still considered unused. -extern crate core; //~ ERROR unused extern crate - -mod m { - use iso1::any as are_you_okay1; - use ::iso2::any as are_you_okay2; - type AreYouOkay1 = dyn iso3::any::Any; - type AreYouOkay2 = dyn (::iso4::any::Any); - - use core::any as are_you_okay3; - use ::core::any as are_you_okay4; - type AreYouOkay3 = dyn core::any::Any; - type AreYouOkay4 = dyn (::core::any::Any); -} - -fn main() {} diff --git a/tests/ui/imports/extern-crate-used.stderr b/tests/ui/imports/extern-crate-used.stderr deleted file mode 100644 index 08bee39141473..0000000000000 --- a/tests/ui/imports/extern-crate-used.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: unused extern crate - --> $DIR/extern-crate-used.rs:18:1 - | -LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ unused - | -note: the lint level is defined here - --> $DIR/extern-crate-used.rs:6:9 - | -LL | #![deny(unused_extern_crates)] - | ^^^^^^^^^^^^^^^^^^^^ -help: remove the unused `extern crate` - | -LL - extern crate core; -LL + - | - -error: aborting due to 1 previous error - diff --git a/tests/ui/lint/unnecessary-extern-crate.rs b/tests/ui/lint/unnecessary-extern-crate.rs deleted file mode 100644 index 7f97a4c469ed8..0000000000000 --- a/tests/ui/lint/unnecessary-extern-crate.rs +++ /dev/null @@ -1,71 +0,0 @@ -//@ edition:2018 - -#![deny(unused_extern_crates)] -#![feature(test)] - -extern crate core; -//~^ ERROR unused extern crate -//~| HELP remove -extern crate core as x; -//~^ ERROR unused extern crate -//~| HELP remove - -extern crate proc_macro; - -#[macro_use] -extern crate test; - -pub extern crate test as y; - -pub extern crate alloc; - -pub(crate) extern crate alloc as a; - -pub(crate) extern crate alloc as b; - -mod foo { - pub(in crate::foo) extern crate alloc as c; - - pub(super) extern crate alloc as d; - - extern crate core; - //~^ ERROR unused extern crate - //~| HELP remove - - extern crate core as x; - //~^ ERROR unused extern crate - //~| HELP remove - - pub extern crate test; - - pub extern crate test as y; - - mod bar { - extern crate core; - //~^ ERROR unused extern crate - //~| HELP remove - - extern crate core as x; - //~^ ERROR unused extern crate - //~| HELP remove - - pub(in crate::foo::bar) extern crate alloc as e; - - fn dummy() { - e::string::String::new(); - } - } - - fn dummy() { - c::string::String::new(); - d::string::String::new(); - } -} - - -fn main() { - a::string::String::new(); - b::string::String::new(); - - proc_macro::TokenStream::new(); -} diff --git a/tests/ui/lint/unnecessary-extern-crate.stderr b/tests/ui/lint/unnecessary-extern-crate.stderr deleted file mode 100644 index db5406bc567d4..0000000000000 --- a/tests/ui/lint/unnecessary-extern-crate.stderr +++ /dev/null @@ -1,73 +0,0 @@ -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:6:1 - | -LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ unused - | -note: the lint level is defined here - --> $DIR/unnecessary-extern-crate.rs:3:9 - | -LL | #![deny(unused_extern_crates)] - | ^^^^^^^^^^^^^^^^^^^^ -help: remove the unused `extern crate` - | -LL - extern crate core; - | - -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:9:1 - | -LL | extern crate core as x; - | ^^^^^^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - extern crate core as x; - | - -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:31:5 - | -LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - extern crate core; - | - -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:35:5 - | -LL | extern crate core as x; - | ^^^^^^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - extern crate core as x; - | - -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:44:9 - | -LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - extern crate core; - | - -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:48:9 - | -LL | extern crate core as x; - | ^^^^^^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - extern crate core as x; - | - -error: aborting due to 6 previous errors - diff --git a/tests/ui/rust-2018/remove-extern-crate.fixed b/tests/ui/rust-2018/remove-extern-crate.fixed deleted file mode 100644 index 19b1dc6fb0130..0000000000000 --- a/tests/ui/rust-2018/remove-extern-crate.fixed +++ /dev/null @@ -1,51 +0,0 @@ -//@ run-rustfix -//@ edition:2018 -//@ check-pass -//@ aux-build:remove-extern-crate.rs -//@ compile-flags:--extern remove_extern_crate - -#![warn(rust_2018_idioms)] -#![allow(dropping_copy_types)] -#![allow(unused_imports)] - - //~ WARNING unused extern crate -// Shouldn't suggest changing to `use`, as `another_name` -// would no longer be added to the prelude which could cause -// compilation errors for imports that use `another_name` in other -// modules. See #57672. -extern crate core as another_name; -use remove_extern_crate; -#[macro_use] -extern crate remove_extern_crate as something_else; - -// Shouldn't suggest changing to `use`, as the `alloc` -// crate is not in the extern prelude - see #54381. -extern crate alloc; - -fn main() { - another_name::mem::drop(3); - another::foo(); - with_visibility::foo(); - remove_extern_crate::foo!(); - bar!(); - alloc::vec![5]; -} - -mod another { - use core; //~ WARNING `extern crate` is not idiomatic - use remove_extern_crate; - - pub fn foo() { - core::mem::drop(4); - remove_extern_crate::foo!(); - } -} - -mod with_visibility { - pub use core; //~ WARNING `extern crate` is not idiomatic - - pub fn foo() { - core::mem::drop(4); - remove_extern_crate::foo!(); - } -} diff --git a/tests/ui/rust-2018/remove-extern-crate.rs b/tests/ui/rust-2018/remove-extern-crate.rs deleted file mode 100644 index 88ef858da147f..0000000000000 --- a/tests/ui/rust-2018/remove-extern-crate.rs +++ /dev/null @@ -1,51 +0,0 @@ -//@ run-rustfix -//@ edition:2018 -//@ check-pass -//@ aux-build:remove-extern-crate.rs -//@ compile-flags:--extern remove_extern_crate - -#![warn(rust_2018_idioms)] -#![allow(dropping_copy_types)] -#![allow(unused_imports)] - -extern crate core; //~ WARNING unused extern crate -// Shouldn't suggest changing to `use`, as `another_name` -// would no longer be added to the prelude which could cause -// compilation errors for imports that use `another_name` in other -// modules. See #57672. -extern crate core as another_name; -use remove_extern_crate; -#[macro_use] -extern crate remove_extern_crate as something_else; - -// Shouldn't suggest changing to `use`, as the `alloc` -// crate is not in the extern prelude - see #54381. -extern crate alloc; - -fn main() { - another_name::mem::drop(3); - another::foo(); - with_visibility::foo(); - remove_extern_crate::foo!(); - bar!(); - alloc::vec![5]; -} - -mod another { - extern crate core; //~ WARNING `extern crate` is not idiomatic - use remove_extern_crate; - - pub fn foo() { - core::mem::drop(4); - remove_extern_crate::foo!(); - } -} - -mod with_visibility { - pub extern crate core; //~ WARNING `extern crate` is not idiomatic - - pub fn foo() { - core::mem::drop(4); - remove_extern_crate::foo!(); - } -} diff --git a/tests/ui/rust-2018/remove-extern-crate.stderr b/tests/ui/rust-2018/remove-extern-crate.stderr deleted file mode 100644 index a530d40188ba2..0000000000000 --- a/tests/ui/rust-2018/remove-extern-crate.stderr +++ /dev/null @@ -1,44 +0,0 @@ -warning: unused extern crate - --> $DIR/remove-extern-crate.rs:11:1 - | -LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ unused - | -note: the lint level is defined here - --> $DIR/remove-extern-crate.rs:7:9 - | -LL | #![warn(rust_2018_idioms)] - | ^^^^^^^^^^^^^^^^ - = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` -help: remove the unused `extern crate` - | -LL - extern crate core; -LL + - | - -warning: `extern crate` is not idiomatic in the new edition - --> $DIR/remove-extern-crate.rs:35:5 - | -LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ - | -help: convert it to a `use` - | -LL - extern crate core; -LL + use core; - | - -warning: `extern crate` is not idiomatic in the new edition - --> $DIR/remove-extern-crate.rs:45:5 - | -LL | pub extern crate core; - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: convert it to a `use` - | -LL - pub extern crate core; -LL + pub use core; - | - -warning: 3 warnings emitted - diff --git a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.fixed b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.fixed deleted file mode 100644 index b4b47dc886bef..0000000000000 --- a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.fixed +++ /dev/null @@ -1,16 +0,0 @@ -//@ edition:2018 -//@ aux-build: remove-extern-crate.rs -//@ run-rustfix -//@ rustfix-only-machine-applicable - -#![warn(rust_2018_idioms)] - - //~ WARNING unused extern crate - //~ WARNING unused extern crate - -mod another { - //~ WARNING unused extern crate - //~ WARNING unused extern crate -} - -fn main() {} diff --git a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs deleted file mode 100644 index f3c591a656adc..0000000000000 --- a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ edition:2018 -//@ aux-build: remove-extern-crate.rs -//@ run-rustfix -//@ rustfix-only-machine-applicable - -#![warn(rust_2018_idioms)] - -#[cfg_attr(test, "macro_use")] //~ ERROR expected -extern crate remove_extern_crate as foo; //~ WARNING unused extern crate -extern crate core; //~ WARNING unused extern crate - -mod another { - #[cfg_attr(test)] //~ ERROR expected - extern crate remove_extern_crate as foo; //~ WARNING unused extern crate - extern crate core; //~ WARNING unused extern crate -} - -fn main() {} diff --git a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.stderr b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.stderr deleted file mode 100644 index 20d5e6aebfd06..0000000000000 --- a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.stderr +++ /dev/null @@ -1,84 +0,0 @@ -error: expected identifier, found `"macro_use"` - --> $DIR/removing-extern-crate-malformed-cfg.rs:8:18 - | -LL | #[cfg_attr(test, "macro_use")] - | ^^^^^^^^^^^ expected identifier - | - = note: for more information, visit -help: must be of the form - | -LL - #[cfg_attr(test, "macro_use")] -LL + #[cfg_attr(predicate, attr1, attr2, ...)] - | - -error: expected one of `(`, `,`, `::`, or `=`, found `` - --> $DIR/removing-extern-crate-malformed-cfg.rs:13:16 - | -LL | #[cfg_attr(test)] - | ^^^^ expected one of `(`, `,`, `::`, or `=` - | - = note: for more information, visit -help: must be of the form - | -LL - #[cfg_attr(test)] -LL + #[cfg_attr(predicate, attr1, attr2, ...)] - | - -warning: unused extern crate - --> $DIR/removing-extern-crate-malformed-cfg.rs:9:1 - | -LL | extern crate remove_extern_crate as foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused - | -note: the lint level is defined here - --> $DIR/removing-extern-crate-malformed-cfg.rs:6:9 - | -LL | #![warn(rust_2018_idioms)] - | ^^^^^^^^^^^^^^^^ - = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` -help: remove the unused `extern crate` - | -LL - #[cfg_attr(test, "macro_use")] -LL - extern crate remove_extern_crate as foo; -LL + - | - -warning: unused extern crate - --> $DIR/removing-extern-crate-malformed-cfg.rs:10:1 - | -LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - extern crate core; -LL + - | - -warning: unused extern crate - --> $DIR/removing-extern-crate-malformed-cfg.rs:14:5 - | -LL | extern crate remove_extern_crate as foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - #[cfg_attr(test)] -LL - extern crate remove_extern_crate as foo; -LL + - | - -warning: unused extern crate - --> $DIR/removing-extern-crate-malformed-cfg.rs:15:5 - | -LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - extern crate core; -LL + - | - -error: aborting due to 2 previous errors; 4 warnings emitted - diff --git a/tests/ui/rust-2018/removing-extern-crate.fixed b/tests/ui/rust-2018/removing-extern-crate.fixed deleted file mode 100644 index e88a84cc93e2a..0000000000000 --- a/tests/ui/rust-2018/removing-extern-crate.fixed +++ /dev/null @@ -1,16 +0,0 @@ -//@ edition:2018 -//@ aux-build:dummy-crate.rs -//@ run-rustfix -//@ check-pass - -#![warn(rust_2018_idioms)] - - //~ WARNING unused extern crate - //~ WARNING unused extern crate - -mod another { - //~ WARNING unused extern crate - //~ WARNING unused extern crate -} - -fn main() {} diff --git a/tests/ui/rust-2018/removing-extern-crate.rs b/tests/ui/rust-2018/removing-extern-crate.rs deleted file mode 100644 index 844377945e02f..0000000000000 --- a/tests/ui/rust-2018/removing-extern-crate.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ edition:2018 -//@ aux-build:dummy-crate.rs -//@ run-rustfix -//@ check-pass - -#![warn(rust_2018_idioms)] - -extern crate dummy_crate as foo; //~ WARNING unused extern crate -extern crate core; //~ WARNING unused extern crate - -mod another { - extern crate dummy_crate as foo; //~ WARNING unused extern crate - extern crate core; //~ WARNING unused extern crate -} - -fn main() {} diff --git a/tests/ui/rust-2018/removing-extern-crate.stderr b/tests/ui/rust-2018/removing-extern-crate.stderr deleted file mode 100644 index b6f8314ce4b64..0000000000000 --- a/tests/ui/rust-2018/removing-extern-crate.stderr +++ /dev/null @@ -1,56 +0,0 @@ -warning: unused extern crate - --> $DIR/removing-extern-crate.rs:8:1 - | -LL | extern crate dummy_crate as foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused - | -note: the lint level is defined here - --> $DIR/removing-extern-crate.rs:6:9 - | -LL | #![warn(rust_2018_idioms)] - | ^^^^^^^^^^^^^^^^ - = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` -help: remove the unused `extern crate` - | -LL - extern crate dummy_crate as foo; -LL + - | - -warning: unused extern crate - --> $DIR/removing-extern-crate.rs:9:1 - | -LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - extern crate core; -LL + - | - -warning: unused extern crate - --> $DIR/removing-extern-crate.rs:12:5 - | -LL | extern crate dummy_crate as foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - extern crate dummy_crate as foo; -LL + - | - -warning: unused extern crate - --> $DIR/removing-extern-crate.rs:13:5 - | -LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ unused - | -help: remove the unused `extern crate` - | -LL - extern crate core; -LL + - | - -warning: 4 warnings emitted - From 1e2d334f7e3e88642d764167a951162d582fde3d Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 19 Jun 2026 18:43:08 +1000 Subject: [PATCH 04/10] [Experiment]: EII can fail if double-linked (e.g, `std` tests) --- library/std/src/io/error.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 86f84ba74ae7e..59aee1f957aca 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -6,16 +6,19 @@ 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 { 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) From 4f058538922898fbfe225ea8d68eb2d24c38f909 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 20 Jun 2026 10:06:45 +1000 Subject: [PATCH 05/10] [Experiment]: Check `dylib` with and without `std` --- library/core/src/io/error.rs | 6 +++--- tests/ui/eii/io_in_core_no_std.rs | 20 ++++++++++++++++++++ tests/ui/eii/io_in_core_with_std.rs | 17 +++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 tests/ui/eii/io_in_core_no_std.rs create mode 100644 tests/ui/eii/io_in_core_with_std.rs diff --git a/library/core/src/io/error.rs b/library/core/src/io/error.rs index 5da087e75b5a9..5405df7a83d71 100644 --- a/library/core/src/io/error.rs +++ b/library/core/src/io/error.rs @@ -11,19 +11,19 @@ pub mod raw_os_error { #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] #[eii] - pub(super) fn decode_error_kind(_: RawOsError) -> ErrorKind { + pub fn decode_error_kind(_: RawOsError) -> ErrorKind { ErrorKind::Uncategorized } #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] #[eii] - pub(super) fn fmt(errno: RawOsError, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + pub fn fmt(errno: RawOsError, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { ::fmt(&decode_error_kind(errno), fmt) } #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] #[eii] - pub(super) fn is_interrupted(errno: RawOsError) -> bool { + pub fn is_interrupted(errno: RawOsError) -> bool { matches!(decode_error_kind(errno), ErrorKind::Interrupted) } } diff --git a/tests/ui/eii/io_in_core_no_std.rs b/tests/ui/eii/io_in_core_no_std.rs new file mode 100644 index 0000000000000..63003ec6965e0 --- /dev/null +++ b/tests/ui/eii/io_in_core_no_std.rs @@ -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::*; diff --git a/tests/ui/eii/io_in_core_with_std.rs b/tests/ui/eii/io_in_core_with_std.rs new file mode 100644 index 0000000000000..541e503dcf72e --- /dev/null +++ b/tests/ui/eii/io_in_core_with_std.rs @@ -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::*; From eed7780742dacefbe34da06e2b94af43b99c5865 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 20 Jun 2026 15:07:32 +1000 Subject: [PATCH 06/10] [Experiment]: Narrow linking errors --- tests/ui/eii/io_in_core_no_std.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/ui/eii/io_in_core_no_std.rs b/tests/ui/eii/io_in_core_no_std.rs index 63003ec6965e0..79f65eff0d1c7 100644 --- a/tests/ui/eii/io_in_core_no_std.rs +++ b/tests/ui/eii/io_in_core_no_std.rs @@ -12,8 +12,18 @@ #![no_std] #![no_implicit_prelude] +// See no_std/simple-runs.rs for details on why this is required. +#[cfg_attr(all(not(target_vendor = "apple"), unix), link(name = "c"))] +#[cfg_attr(target_vendor = "apple", link(name = "System"))] +extern "C" {} + #[panic_handler] -fn panic_handler(_info: &core::panic::PanicInfo<'_>) -> ! { +fn panic_handler(_: &PanicInfo<'_>) -> ! { + loop {} +} + +#[lang = "eh_personality"] +extern "C" fn rust_eh_personality(_: i32, _: i32, _: u64, _: *mut (), _: *mut ()) -> i32 { loop {} } From 6ea5c4c6542931b3a6c2a02c3b8008261ee194c9 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 20 Jun 2026 15:21:50 +1000 Subject: [PATCH 07/10] [Experiment]: Explicitly disable EII usage for Apple and MinGW --- library/core/src/io/error.rs | 4 ++++ library/std/src/io/error.rs | 33 ++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/library/core/src/io/error.rs b/library/core/src/io/error.rs index 5405df7a83d71..bedbf49ebc005 100644 --- a/library/core/src/io/error.rs +++ b/library/core/src/io/error.rs @@ -6,6 +6,10 @@ use crate::fmt; #[doc(hidden)] pub mod raw_os_error { #![expect(dead_code)] + // FIXME: Apple platforms do not yet support weak linkage + #![cfg(not(target_vendor = "apple"))] + // FIXME: Windows GNU (e.g., MinGW) does not yet support weak linkage + #![cfg(not(all(target_os = "windows", target_env = "gnu")))] use super::{ErrorKind, RawOsError}; diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 59aee1f957aca..7225885cc9cf5 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -6,22 +6,29 @@ pub use core::io::ErrorKind; #[unstable(feature = "raw_os_error_ty", issue = "107792")] pub use core::io::RawOsError; +// `std` is linked twice during testing which causes duplicate strong symbols. #[cfg(not(test))] -#[core::io::raw_os_error::decode_error_kind] -fn raw_os_error_decode(code: RawOsError) -> ErrorKind { - sys::io::decode_error_kind(code) -} +// FIXME: Apple platforms do not yet support weak linkage +#[cfg(not(target_vendor = "apple"))] +// FIXME: Windows GNU (e.g., MinGW) does not yet support weak linkage +#[cfg(not(all(target_os = "windows", target_env = "gnu")))] +mod eii_impls { + use super::*; + + #[core::io::raw_os_error::decode_error_kind] + fn raw_os_error_decode(code: RawOsError) -> ErrorKind { + 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)) -} + #[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) + #[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 From f615da5f365289e23e7489ffccfe137571b11fd6 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 20 Jun 2026 15:44:10 +1000 Subject: [PATCH 08/10] [Experiment]: Make core "not platform specific" --- library/core/src/io/error.rs | 46 ++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/library/core/src/io/error.rs b/library/core/src/io/error.rs index bedbf49ebc005..605c692917009 100644 --- a/library/core/src/io/error.rs +++ b/library/core/src/io/error.rs @@ -5,30 +5,36 @@ 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)] - // FIXME: Apple platforms do not yet support weak linkage - #![cfg(not(target_vendor = "apple"))] - // FIXME: Windows GNU (e.g., MinGW) does not yet support weak linkage - #![cfg(not(all(target_os = "windows", target_env = "gnu")))] + #![allow(dead_code)] - use super::{ErrorKind, RawOsError}; + cfg_select! { + target_vendor = "apple" => { + // FIXME: Apple platforms do not yet support weak linkage + } + all(target_os = "windows", target_env = "gnu") => { + // FIXME: Windows GNU (e.g., MinGW) does not yet support weak linkage + } + _ => { + 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 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 { - ::fmt(&decode_error_kind(errno), fmt) - } + #[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 { + ::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) + #[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) + } + } } } From 0d313114636529461888020ed5eed54a07443070 Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Sat, 20 Jun 2026 16:55:15 +1000 Subject: [PATCH 09/10] Update tests/ui/eii/io_in_core_no_std.rs --- tests/ui/eii/io_in_core_no_std.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/eii/io_in_core_no_std.rs b/tests/ui/eii/io_in_core_no_std.rs index 79f65eff0d1c7..c0d150b264c8d 100644 --- a/tests/ui/eii/io_in_core_no_std.rs +++ b/tests/ui/eii/io_in_core_no_std.rs @@ -18,7 +18,7 @@ extern "C" {} #[panic_handler] -fn panic_handler(_: &PanicInfo<'_>) -> ! { +fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! { loop {} } From c7b99ec4bafb19d1b7b08c4b94120206c8047460 Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Sat, 20 Jun 2026 16:55:26 +1000 Subject: [PATCH 10/10] Update tests/ui/eii/io_in_core_no_std.rs --- tests/ui/eii/io_in_core_no_std.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui/eii/io_in_core_no_std.rs b/tests/ui/eii/io_in_core_no_std.rs index c0d150b264c8d..16771ed03ac8b 100644 --- a/tests/ui/eii/io_in_core_no_std.rs +++ b/tests/ui/eii/io_in_core_no_std.rs @@ -9,6 +9,7 @@ #![feature(core_io_internals)] #![feature(core_io)] #![feature(raw_os_error_ty)] +#![feature(lang_items)] #![no_std] #![no_implicit_prelude]