Skip to content

Conversation

CDirkx
Copy link
Contributor

@CDirkx CDirkx commented Apr 21, 2021

This moves sys_common::rwlock::StaticRwLock, RWLockReadGuard and RWLockWriteGuard to sys::unix::rwlock. They are already #[cfg(unix)] and don't need to be in sys_common.

Part of #84187.

@rust-highfive
Copy link
Contributor

r? @dtolnay

(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 Apr 21, 2021
@CDirkx
Copy link
Contributor Author

CDirkx commented Apr 21, 2021

I was also thinking about removing sys_common::rwlock entirely, since sys_common::rwlock::RWLock doesn't provide any meaningful abstraction (full delegation to the sys implementation). However the comments about what is and isn't undefined behavior are useful to keep around.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks, looks good.

Regarding sys_common::rwlock::RWLock — it looks to me like that wrapper type is serving exactly the purpose of a trait, i.e. a consistent set of methods with documented guarantees that the various implementations must provide. So how about replacing it with a RWLock trait instead? The trait would take the place of the current wrapper, in sys_common. The implementations would stay in sys, and would now have all their methods in a trait impl rather than inherent methods. The trait fulfills the current role of the wrapper type by ensuring that the various implementations all expose the same API.

@dtolnay
Copy link
Member

dtolnay commented Apr 21, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 21, 2021

📌 Commit eb9b0f6 has been approved by dtolnay

@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 Apr 21, 2021
@CDirkx
Copy link
Contributor Author

CDirkx commented Apr 21, 2021

Yeah using traits for that could be a good idea. I'll look into other types that may also be applicable to.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 22, 2021
Move `sys_common::rwlock::StaticRWLock` etc. to `sys::unix::rwlock`

This moves `sys_common::rwlock::StaticRwLock`, `RWLockReadGuard` and `RWLockWriteGuard` to `sys::unix::rwlock`. They are already `#[cfg(unix)]` and don't need to be in `sys_common`.
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 22, 2021
Rollup of 7 pull requests

Successful merges:

 - rust-lang#84343 (Remove `ScopeTree::closure_tree`)
 - rust-lang#84376 (Uses flex to fix formatting of h1 at any width)
 - rust-lang#84377 (Followup to rust-lang#83944)
 - rust-lang#84396 (Update LLVM submodule)
 - rust-lang#84402 (Move `sys_common::rwlock::StaticRWLock` etc. to `sys::unix::rwlock`)
 - rust-lang#84404 (Check for intrinsics before coercing to a function pointer)
 - rust-lang#84413 (Remove `sys::args::Args::inner_debug` and use `Debug` instead)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit aac5125 into rust-lang:master Apr 22, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 22, 2021
@CDirkx CDirkx deleted the rwlock branch April 22, 2021 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants