Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AsFd implementations for stdio lock types on WASI. #101768

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sunfishcode
Copy link
Member

@sunfishcode sunfishcode commented Sep 13, 2022

This mirrors the implementations on Unix platforms, and also mirrors the existing AsRawFd impls.

This is similar to #100892, but is for the *Lock types.

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 13, 2022
@rustbot
Copy link
Collaborator

rustbot commented Sep 13, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive
Copy link
Collaborator

rust-highfive commented Sep 13, 2022

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 13, 2022
@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Sep 17, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Sep 17, 2022

📌 Commit d8c2c42 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors 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 Sep 17, 2022
@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Sep 17, 2022

@bors r-

Are you sure this actually compiles on wasi? I don't see where StdinLock (or the other types) is imported in that module, maybe just missing something obvious. (Went to go look for stability implications of this change)

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 17, 2022
This mirrors the implementations on Unix platforms, and also mirrors the
existing `AsRawFd` impls.

This is similar to rust-lang#100892, but is for the `*Lock` types.
@sunfishcode sunfishcode force-pushed the sunfishcode/wasi-stdio-lock-asfd branch from d8c2c42 to 6acf998 Compare Sep 22, 2022
@sunfishcode sunfishcode force-pushed the sunfishcode/wasi-stdio-lock-asfd branch from 6acf998 to e97755c Compare Sep 23, 2022
@sunfishcode
Copy link
Member Author

sunfishcode commented Sep 23, 2022

@Mark-Simulacrum Ah, you're right. That's now fixed, and as you mention, the compiler required stability attributes. I marked them "stable", using the io_safety feature, on the theory that implementing AsFd for these types is something that logically belongs to that feature, and was only omitted as an oversight.

@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Sep 23, 2022

Hm, ok. If these are stable surface area then they need a libs-api FCP; r? @joshtriplett

@Mark-Simulacrum Mark-Simulacrum added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 23, 2022
@joshtriplett
Copy link
Member

joshtriplett commented Sep 23, 2022

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Sep 23, 2022

Team member @joshtriplett 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.

@rfcbot 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. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Sep 23, 2022
@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Sep 24, 2022
@rfcbot
Copy link

rfcbot commented Sep 24, 2022

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

impl<'a> AsFd for io::StdinLock<'a> {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(0) }
Copy link
Contributor

@hamza1311 hamza1311 Sep 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exactly is this correct? A safety comment here would be great to have for someone stumbling upon this without having prior knowledge of the API and WASI spec

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. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants