Skip to content

core: io: clean unused_variables lint under no_io_statics - #163633

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
ojeda:unused-variable-set_functions
Oct 3, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
ojeda:unused-variable-set_functions

Conversation

@ojeda

@ojeda ojeda commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

When building core with --cfg no_io_statics, the compiler warns:

error: unused variable: `f`
 --> .../library/core/src/io/error/os_functions.rs:9:36
  |
9 | pub(super) unsafe fn set_functions(f: &'static OsFunctions) {
  |                                    ^ help: if this is intentional, prefix it with an underscore: `_f`
  |
  = note: `-D unused-variables` implied by `-D warnings`
  = help: to override `-D warnings` add `#[allow(unused_variables)]`

Thus clean it up.


If the signature is preferred to be exactly the same one as the os_functions_atomic.rs one, then we could allow it instead.

When building `core` with `--cfg no_io_statics`, the compiler warns:

    error: unused variable: `f`
     --> .../library/core/src/io/error/os_functions.rs:9:36
      |
    9 | pub(super) unsafe fn set_functions(f: &'static OsFunctions) {
      |                                    ^ help: if this is intentional, prefix it with an underscore: `_f`
      |
      = note: `-D unused-variables` implied by `-D warnings`
      = help: to override `-D warnings` add `#[allow(unused_variables)]`

Thus clean it up.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 2, 2026
@rustbot

rustbot commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from Darksonn, JohnTitor, Mark-Simulacrum, clarfonthey

Similar to the existing tests for other `cfg`s like `no_fp_fmt_parse`,
add one for `no_io_statics`.

This should prevent issues like the one in the parent commit.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Oct 2, 2026
@ojeda

ojeda commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

I added a test like the other ones we added in the past, to cover this. It passes when the first commit is applied.

ojeda pushed a commit to Rust-for-Linux/linux that referenced this pull request Oct 2, 2026
In upstream Rust, PR #155625 moved `std::io::Error` into `core` under
the `core_io` feature gate. To support decoding and formatting raw OS
errors (`RawOsError`) from within `core` without depending on OS
facilities, `core` introduced a global atomic pointer:

	static OS_FUNCTIONS: atomic::AtomicPtr<OsFunctions>

At runtime, `std` registers its OS error vtable with this pointer via
`set_functions()`, which uses `core::sync::atomic` to modify the value
of this atomic variable.

To ensure that `core` does not introduce usage of `core::sync::atomic`
into the kernel image, set the `no_io_statics` cfg, which removes this
logic from the build.

Note that changing the `OS_FUNCTIONS` global is only possible via the
unstable `from_raw_os_error_with_functions()` function from `core`,
which is called by `std`. There is no way for us to invoke it from the
kernel, as we do not use `std`.

[ Pass `-Aunused_variables` to `core` to avoid:

    error: unused variable: `f`
     --> .../library/core/src/io/error/os_functions.rs:9:36
      |
    9 | pub(super) unsafe fn set_functions(f: &'static OsFunctions) {
      |                                    ^ help: if this is intentional, prefix it with an underscore: `_f`
      |
      = note: `-D unused-variables` implied by `-D warnings`
      = help: to override `-D warnings` add `#[allow(unused_variables)]`

  I sent a PR upstream [1] to clean it up and to add a test to check
  that `core` builds are warning-free with the `cfg` enabled, similar
  to what I added for other `cfg`s.

  Link: rust-lang/rust#163633 [1]

    - Miguel ]

Link: rust-lang/rust#155625
Link: rust-lang/rust#154046
Link: rust-lang/libs-team#755
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260904-no-io-statics-v1-1-a2386eb0d255@google.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

@JohnTitor JohnTitor left a comment •

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.

@rust-bors

rust-bors Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit f3f9adf has been approved by JohnTitor

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 2, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 3, 2026
…s, r=JohnTitor

core: io: clean `unused_variables` lint under `no_io_statics`

When building `core` with `--cfg no_io_statics`, the compiler warns:

    error: unused variable: `f`
     --> .../library/core/src/io/error/os_functions.rs:9:36
      |
    9 | pub(super) unsafe fn set_functions(f: &'static OsFunctions) {
      |                                    ^ help: if this is intentional, prefix it with an underscore: `_f`
      |
      = note: `-D unused-variables` implied by `-D warnings`
      = help: to override `-D warnings` add `#[allow(unused_variables)]`

Thus clean it up.

---

If the signature is preferred to be exactly the same one as the `os_functions_atomic.rs` one, then we could `allow` it instead.
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 3, 2026
…s, r=JohnTitor

core: io: clean `unused_variables` lint under `no_io_statics`

When building `core` with `--cfg no_io_statics`, the compiler warns:

    error: unused variable: `f`
     --> .../library/core/src/io/error/os_functions.rs:9:36
      |
    9 | pub(super) unsafe fn set_functions(f: &'static OsFunctions) {
      |                                    ^ help: if this is intentional, prefix it with an underscore: `_f`
      |
      = note: `-D unused-variables` implied by `-D warnings`
      = help: to override `-D warnings` add `#[allow(unused_variables)]`

Thus clean it up.

---

If the signature is preferred to be exactly the same one as the `os_functions_atomic.rs` one, then we could `allow` it instead.
rust-bors Bot pushed a commit that referenced this pull request Oct 3, 2026
Rollup of 6 pull requests

Successful merges:

 - #163627 (Add documentation for the `no_main` and `repr` attributes)
 - #163663 (reflection: fix ICE when TypeId::info called on ADT)
 - #138744 (Add methods to TCP and UDP sockets to modify hop limit (refresh of #94678))
 - #163633 (core: io: clean `unused_variables` lint under `no_io_statics`)
 - #163681 (Make the tracking issue template better suited for experiments)
 - #163685 (Avoid long iterator chain in all_rust_features)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 3, 2026
…s, r=JohnTitor

core: io: clean `unused_variables` lint under `no_io_statics`

When building `core` with `--cfg no_io_statics`, the compiler warns:

    error: unused variable: `f`
     --> .../library/core/src/io/error/os_functions.rs:9:36
      |
    9 | pub(super) unsafe fn set_functions(f: &'static OsFunctions) {
      |                                    ^ help: if this is intentional, prefix it with an underscore: `_f`
      |
      = note: `-D unused-variables` implied by `-D warnings`
      = help: to override `-D warnings` add `#[allow(unused_variables)]`

Thus clean it up.

---

If the signature is preferred to be exactly the same one as the `os_functions_atomic.rs` one, then we could `allow` it instead.
rust-bors Bot pushed a commit that referenced this pull request Oct 3, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #163645 (add `ignore-compare-mode-next-solver` to all next-solver tests)
 - #163663 (reflection: fix ICE when TypeId::info called on ADT)
 - #163454 (Improve suggestion for lifetime preceding type in generics)
 - #163561 (tests: accept noundef in a couple more places)
 - #163633 (core: io: clean `unused_variables` lint under `no_io_statics`)
 - #163681 (Make the tracking issue template better suited for experiments)
 - #163685 (Avoid long iterator chain in all_rust_features)
 - #163690 (refactor: migrate to LLVM-C's `LLVMGetOrInsertFunction`)

Failed merges:

 - #161491 (Rip out old solver coherence)
@rust-bors
rust-bors Bot merged commit 151e58b into rust-lang:main Oct 3, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 3, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 3, 2026
Rollup merge of #163633 - ojeda:unused-variable-set_functions, r=JohnTitor

core: io: clean `unused_variables` lint under `no_io_statics`

When building `core` with `--cfg no_io_statics`, the compiler warns:

    error: unused variable: `f`
     --> .../library/core/src/io/error/os_functions.rs:9:36
      |
    9 | pub(super) unsafe fn set_functions(f: &'static OsFunctions) {
      |                                    ^ help: if this is intentional, prefix it with an underscore: `_f`
      |
      = note: `-D unused-variables` implied by `-D warnings`
      = help: to override `-D warnings` add `#[allow(unused_variables)]`

Thus clean it up.

---

If the signature is preferred to be exactly the same one as the `os_functions_atomic.rs` one, then we could `allow` it instead.
@ojeda
ojeda deleted the unused-variable-set_functions branch October 11, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants