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

Consolidate some duplicate code in the sys modules. #75749

Merged
merged 3 commits into from
Sep 16, 2020

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Aug 20, 2020

This consolidates some modules which were duplicated throughout the sys module. The intent is to make it easier to update and maintain this code. This mainly affects the wasi, sgx, and "unsupported" targets.

I explicitly skipped hermit, cloudabi, and vxworks. These tier-3 targets have copied large sections of the sys tree. I don't think they should have, but I don't want to put effort into changing them. It also doesn't help that there aren't any scripts or instructions for building them.

There are still sections of duplicate code here and there, but this PR covers the easy parts where entire modules are the same.

@rust-highfive
Copy link
Collaborator

r? @sfackler

(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 Aug 20, 2020
@ehuss
Copy link
Contributor Author

ehuss commented Aug 20, 2020

cc @alexcrichton modifies wasi
cc @jethrogb modifies sgx

Copy link
Contributor

@jethrogb jethrogb left a comment

Choose a reason for hiding this comment

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

Thanks for the ping! LGTM modulo one comment. Also I assume if we do ever implement (parts) of these APIs we can just (partially) undo this change.

pub mod fs;
#[path = "../unsupported/io.rs"]
pub mod io;
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems a little strange to pull the IoSlice types from somewhere with “unsupported” in the name, as these types are actually used and supported on this target.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, good point. I can't think of a good place to put this module, since there isn't a location for "basic implementation that is not Unix". Would it make sense to add a sys::basic module that contained code like this? The only other "functional" code in the unsupported tree is:

  • cmath.rs (basic definitions from compiler-builtins)
  • common.rs strlen (very simple pure-rust C-strlen implementation)

@bors
Copy link
Contributor

bors commented Sep 3, 2020

☔ The latest upstream changes (presumably #75971) made this pull request unmergeable. Please resolve the merge conflicts.

@ehuss
Copy link
Contributor Author

ehuss commented Sep 10, 2020

@sfackler do you think you'll be able to review this?

@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Sep 15, 2020
@Dylan-DPC-zz
Copy link

merging this given that there was one approval even though not from the reviewer.

@bors r=sfackler

@bors
Copy link
Contributor

bors commented Sep 15, 2020

📌 Commit 90b941d05147a81a8236365bcf380e01f20a3ed1 has been approved by sfackler

@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 15, 2020
@bors
Copy link
Contributor

bors commented Sep 15, 2020

⌛ Testing commit 90b941d05147a81a8236365bcf380e01f20a3ed1 with merge 7ee2bd15797d69501f36b94f083f18031d11893c...

@bors
Copy link
Contributor

bors commented Sep 15, 2020

💔 Test failed - checks-actions

@bors bors 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 Sep 15, 2020
@jethrogb
Copy link
Contributor

error: couldn't read library/std/src/sys/wasm/../unsupported/path.rs: No such file or directory (os error 2)
  --> library/std/src/sys/wasm/mod.rs:31:1
   |
31 | pub mod path;
   | ^^^^^^^^^^^^^

@ehuss
Copy link
Contributor Author

ehuss commented Sep 15, 2020

Not sure how I missed that attribute, I thought I had tested it.

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Sep 15, 2020

📌 Commit 25cca07 has been approved by alexcrichton

@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 15, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 16, 2020
Rollup of 10 pull requests

Successful merges:

 - rust-lang#73955 (deny(unsafe_op_in_unsafe_fn) in libstd/process.rs)
 - rust-lang#75146 (Detect overflow in proc_macro_server subspan)
 - rust-lang#75304 (Note when a a move/borrow error is caused by a deref coercion)
 - rust-lang#75749 (Consolidate some duplicate code in the sys modules.)
 - rust-lang#75882 (Use translated variable for test string)
 - rust-lang#75886 (Test that bounds checks are elided for [..index] after .position())
 - rust-lang#76048 (Initial support for riscv32gc_unknown_linux_gnu)
 - rust-lang#76198 (Make some Ordering methods const)
 - rust-lang#76689 (Upgrade to pulldown-cmark 0.8.0)
 - rust-lang#76763 (Update cargo)

Failed merges:

r? `@ghost`
@bors bors merged commit 034af08 into rust-lang:master Sep 16, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

9 participants