Repository navigation
core: io: clean unused_variables lint under no_io_statics - #163633
Merged
rust-bors[bot] merged 2 commits intoOct 3, 2026
Merged
Conversation
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>
Collaborator
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
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>
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
approved these changes
Oct 2, 2026
Contributor
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.
This was referenced Oct 3, 2026
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 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.
45 of 80 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When building
corewith--cfg no_io_statics, the compiler warns:Thus clean it up.
If the signature is preferred to be exactly the same one as the
os_functions_atomic.rsone, then we couldallowit instead.