Skip to content

Make std::fs::File Send on UEFI#154003

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ginnyTheCat:uefi-file-send
Apr 18, 2026
Merged

Make std::fs::File Send on UEFI#154003
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ginnyTheCat:uefi-file-send

Conversation

@ginnyTheCat

@ginnyTheCat ginnyTheCat commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Similarly to #150990 since UEFI has no threads, this should be safe.

@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 Mar 17, 2026
@rustbot

rustbot commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, joboet

@Mark-Simulacrum

Mark-Simulacrum commented Mar 23, 2026

Copy link
Copy Markdown
Member

Hm, I'm wondering if this justification is really enough. If it is, it seems like this is something we should teach the compiler about, rather than putting it in code where it might be left in by accident / copied into the wrong place / etc. I'll start a thread on Zulip about that (edit: https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/Send.20on.20thread-free.20targets/with/580986733).

I guess this is technically also making a new stable guarantee (although on a tier 2 target), so it probably needs FCP? I see that wasn't applied in #150990, perhaps because it seems like this is 'obvious', but it seems like we should at least raise it with libs-api.

@Mark-Simulacrum Mark-Simulacrum added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Mar 23, 2026
@Mark-Simulacrum

Copy link
Copy Markdown
Member

Also, can you say a bit more about the rationale for this? What specifically is needing a Send bound that's making this needed on the target? I see the other PR mentions remote-test-server, but I'm not seeing any merged PRs there recently that seem related.

@ginnyTheCat

ginnyTheCat commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

this is something we should teach the compiler about

I agree. Especially on wasm there is a lot of unsafe code that relies on there only being one thread (in wasm-bindgen for example if i remember correctly). This could be avoided by everything implementing Send on targets without thread spawn support (UEFI or wasm32 in the browser).

can you say a bit more about the rationale for this?

This isn't really related to any core Rust things like the other PR is, but me having code that kind of looks like this:

let file = File::open("data")?;
thread::scope(|s| {
    for _ in 1..available_parallelism().map_or(2, NonZero::get) {
        if Builder::new().spawn_scoped(s, || worker(&file)).is_err() {
            break;
        }
    }
    worker(&file);
});

This would only use a single thread on UEFI while being multithreaded everywhere else. Currently this has to be done using #[cfg] since File is not Send on UEFI (while being on all other targets).

@Amanieu

Amanieu commented Mar 24, 2026

Copy link
Copy Markdown
Member

We discussed this in the @rust-lang/libs-api meeting. We agree that File should always implement Send for several reasons:

  • It's documented as such in the standard library docs, which make no mention of this being dependent on the target.
  • As a general rule, the std API (unlike core) isn't async-signal-safe. This means that it cannot be used in signal handlers or interrupt handlers, even for types that implement Send.
  • Finally, the standard library on UEFI only works on the boot CPU. While it is possible to run code on secondary CPUs with asm, this should be treated the same way as interrupt handlers and be restricted to core.

As a side note, #150990 really should have gone through a libs-api FCP since it is making an API change, even if only a tier 2 target.

@rfcbot merge libs-api

@Amanieu Amanieu removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Mar 24, 2026
@rust-rfcbot

rust-rfcbot commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Mar 24, 2026
Comment thread library/std/src/sys/fs/uefi.rs Outdated
@rustbot

This comment has been minimized.

@rust-rfcbot rust-rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Apr 7, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Apr 17, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

@Mark-Simulacrum

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

📌 Commit a227bc7 has been approved by Mark-Simulacrum

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 Apr 18, 2026
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 18, 2026
…-Simulacrum

Make std::fs::File Send on UEFI

Similarly to rust-lang#150990 since UEFI has no threads, this should be safe.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 18, 2026
…-Simulacrum

Make std::fs::File Send on UEFI

Similarly to rust-lang#150990 since UEFI has no threads, this should be safe.
rust-bors Bot pushed a commit that referenced this pull request Apr 18, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #150230 (spec next chunk for trustedlen)
 - #155284 (net::tcp/udp: fix docs about how set_nonblocking is implemented)
 - #146870 (fix: add aliasing rules for Box)
 - #154003 (Make std::fs::File Send on UEFI)
 - #155187 (std: fix HashMap RNG docs wording)
 - #155255 (Document why `layout.align() + layout.size()` doesn't overflow)
 - #155351 (Reorganize tests from `tests/ui/issues/`)
 - #155406 (std: Update dependency on `wasi` crate)
 - #155447 (Simplify `parse_limited`)
 - #155481 (Delete `SizeSkeleton::Generic`)
@rust-bors rust-bors Bot merged commit f766867 into rust-lang:main Apr 18, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 18, 2026
rust-timer added a commit that referenced this pull request Apr 18, 2026
Rollup merge of #154003 - ginnyTheCat:uefi-file-send, r=Mark-Simulacrum

Make std::fs::File Send on UEFI

Similarly to #150990 since UEFI has no threads, this should be safe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. 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. to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants