Skip to content

Move std::io::Error into core#155625

Merged
rust-bors[bot] merged 14 commits into
rust-lang:mainfrom
bushrat011899:core_io_error
Jun 29, 2026
Merged

Move std::io::Error into core#155625
rust-bors[bot] merged 14 commits into
rust-lang:mainfrom
bushrat011899:core_io_error

Conversation

@bushrat011899

@bushrat011899 bushrat011899 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

View all comments

ACP: rust-lang/libs-team#755
Tracking issue: #154046
Related: #155574
Related: #152918

Description

Moves std::io::Error into core, deferring Box-adjacent methods to incoherent implementations in alloc, and RawOsError methods to std. This requires some substantial changes to the internals of Error, but none of them are breaking changes or externally visible.

Notably, I've replaced usage of Box with a wrapper around a pointer and an appropriate drop function. This requires the addition of quite a few lines of unsafe, but is required to work around Box only being accessible from alloc. Additionally, an atomic pointer to a VTable is used for working with RawOsError in core, since we cannot know the required implementations without std.

As mention in this comment, there may be concern around having a static AtomicPtr in core for certain users. I've added a configuration option no_io_statics which (similar to no_sync/etc. in alloc) can be used to prevent their inclusion in core. When active, the fallback default implementation will always be used.


Notes

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 21, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment thread library/core/src/io/error/os_functions_atomic.rs
@bushrat011899 bushrat011899 force-pushed the core_io_error branch 2 times, most recently from 93b1fa3 to d3835aa Compare April 22, 2026 03:06
Comment thread library/core/src/io/error.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@programmerjake

Copy link
Copy Markdown
Member

example of how to link from core's docs to std: https://doc.rust-lang.org/1.95.0/src/core/str/mod.rs.html#200

@rustbot rustbot added the O-unix Operating system: Unix-like label Apr 22, 2026
@bushrat011899

Copy link
Copy Markdown
Contributor Author

example of how to link from core's docs to std: https://doc.rust-lang.org/1.95.0/src/core/str/mod.rs.html#200

That's a clever trick I never knew about! Looks like it's also required for linking to incoherent implementations even within the file that creates them too.

@bushrat011899

This comment has been minimized.

@rustbot rustbot removed the O-unix Operating system: Unix-like label Apr 22, 2026
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the O-unix Operating system: Unix-like label Apr 22, 2026
@bushrat011899

This comment has been minimized.

@rustbot rustbot removed the O-unix Operating system: Unix-like label Apr 22, 2026
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the O-unix Operating system: Unix-like label Apr 22, 2026
@bushrat011899

This comment has been minimized.

@rustbot rustbot removed the O-unix Operating system: Unix-like label Apr 22, 2026
@programmerjake

Copy link
Copy Markdown
Member

label -O-unix
See

maybe just leave it until you get the PR to work, that way there's less comment spam.

@Mark-Simulacrum

Copy link
Copy Markdown
Member

@bors r+ rollup=never

@rust-bors

rust-bors Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0a1de1d has been approved by Mark-Simulacrum

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1. This pull request will be tested once the tree is reopened.

@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 Jun 28, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors p=1
Scheduling

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 28, 2026
Move `std::io::Error` into `core`





ACP: rust-lang/libs-team#755
Tracking issue: #154046
Related: #155574
Related: #152918

## Description

Moves `std::io::Error` into `core`, deferring `Box`-adjacent methods to incoherent implementations in `alloc`, and `RawOsError` methods to `std`. This requires some substantial changes to the internals of `Error`, but none of them are breaking changes or externally visible.

Notably, I've replaced usage of `Box` with a wrapper around a pointer and an appropriate drop function. This requires the addition of quite a few lines of unsafe, but is required to work around `Box` only being accessible from `alloc`. Additionally, an atomic pointer to a VTable is used for working with `RawOsError` in `core`, since we cannot know the required implementations without `std`.

As mention in [this comment](#155625 (comment)), there may be concern around having a static `AtomicPtr` in `core` for certain users. I've added a configuration option `no_io_statics` which (similar to `no_sync`/etc. in `alloc`) can be used to prevent their inclusion in `core`. When active, the fallback default implementation will always be used.

---

## Notes

* This PR adopts the VTable technique from #152918
* This PR builds on my previous PR #155574
* No AI tooling of any kind was used during the creation of this PR.
@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 28, 2026
@rust-bors

rust-bors Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 281a1ae failed: CI. Failed job:

Previous limit of 40,000 is now broken by 2,281 bytes.
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 28, 2026
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jun 28, 2026
@bushrat011899

bushrat011899 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Failure seems to be caused by the final WASM output of the wasm-panic-small make test being at least 2,281 bytes larger that previous (limit in the test is set to 40,000 bytes, but I'm unsure how lenient that limit was).

I'm pushing a commit which increases the limit to 45,000 bytes, as I'm unsure what could be done otherwise. The wasm-stringify-ints-small test has a limit of 50,000 bytes which does pass, so I suspect the 40,000 limit was just very close to being broken already, and this PR was the last straw.

@bushrat011899

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 28, 2026
@jhpratt

jhpratt commented Jun 29, 2026

Copy link
Copy Markdown
Member

@bors r=Mark-Simulacrum

@rust-bors

rust-bors Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3fa872c has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: Mark-Simulacrum
Duration: 3h 7m 37s
Pushing 7fb284d to main...

@github-actions

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing df6ee90 (parent) -> 7fb284d (this PR)

Test differences

Show 222 test diffs

222 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 7fb284d9037fa54f6a9b24261c82b394472cbfd7 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-msvc-alt: 2h 4m -> 2h 42m (+30.2%)
  2. dist-i586-gnu-i586-i686-musl: 1h 15m -> 1h 35m (+26.4%)
  3. i686-msvc-1: 3h -> 2h 13m (-25.8%)
  4. dist-powerpc64le-linux-gnu: 1h 34m -> 1h 17m (-17.7%)
  5. dist-i686-mingw: 2h 31m -> 2h 8m (-15.0%)
  6. dist-aarch64-msvc: 1h 39m -> 1h 50m (+11.1%)
  7. dist-x86_64-apple: 1h 42m -> 1h 52m (+9.1%)
  8. dist-x86_64-solaris: 1h 40m -> 1h 31m (-9.0%)
  9. x86_64-msvc-ext1: 2h 3m -> 2h 13m (+8.3%)
  10. aarch64-msvc-2: 1h 43m -> 1h 35m (-7.2%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (7fb284d): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
1.0% [0.5%, 2.6%] 9
Regressions ❌
(secondary)
1.4% [0.2%, 7.7%] 23
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.7% [-6.0%, -3.2%] 6
All ❌✅ (primary) 1.0% [0.5%, 2.6%] 9

Max RSS (memory usage)

Results (secondary -0.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.3% [2.3%, 2.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.0% [-2.4%, -1.7%] 3
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.0%, secondary 0.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
5.2% [2.4%, 6.9%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.4% [-5.9%, -3.6%] 4
All ❌✅ (primary) 2.0% [2.0%, 2.0%] 1

Binary size

Results (primary 0.8%, secondary 1.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.9% [0.0%, 2.5%] 37
Regressions ❌
(secondary)
2.0% [0.0%, 2.5%] 91
Improvements ✅
(primary)
-0.1% [-0.3%, -0.1%] 5
Improvements ✅
(secondary)
-3.6% [-7.2%, -0.9%] 8
All ❌✅ (primary) 0.8% [-0.3%, 2.5%] 42

Bootstrap: 485.504s -> 486.093s (0.12%)
Artifact size: 393.08 MiB -> 393.66 MiB (0.15%)

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 merged-by-bors This PR was explicitly merged by bors. O-unix Operating system: Unix-like perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.