core::sync: rename Exclusive to SyncView and make improvements#153038
core::sync: rename Exclusive to SyncView and make improvements#153038rust-bors[bot] merged 7 commits intorust-lang:mainfrom
Exclusive to SyncView and make improvements#153038Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
0967996 to
b5f2783
Compare
This comment has been minimized.
This comment has been minimized.
library/core/src/sync/sync_view.rs
Outdated
| #[rustc_const_unstable(feature = "const_iter", issue = "92476")] | ||
| impl<T> const Iterator for SyncView<T> | ||
| where | ||
| T: [const] Iterator + ?Sized, |
There was a problem hiding this comment.
This needs to be bounded on Sync – size_hint takes &self.
There was a problem hiding this comment.
We figured this was similar to the case with Debug, which doesn’t need Sync despite taking &self because it doesn’t inspect self in any way. The default definition for size_hint is used here (so giving no information about the underlying iterator) instead of delegating through (which would require T: Sync).
|
Since you’re already here and reviewing it anyway, may as well make it official: r? @joboet |
b5f2783 to
ef2873c
Compare
This comment has been minimized.
This comment has been minimized.
|
r? libs-api |
ef2873c to
e39d61b
Compare
This comment has been minimized.
This comment has been minimized.
e39d61b to
b5ca39e
Compare
This comment has been minimized.
This comment has been minimized.
b5ca39e to
010f4db
Compare
This comment has been minimized.
This comment has been minimized.
010f4db to
7900ef4
Compare
This comment has been minimized.
This comment has been minimized.
7900ef4 to
e2f838b
Compare
This comment has been minimized.
This comment has been minimized.
|
This mostly LGTM, except for the |
We will remove it, then; what would be the best way for us to bring up the |
This moves the inherent `get_mut` method to be `AsMut::as_mut`, and renames `get_pin_mut` to `as_pin_mut` accordingly. It also constifies the `AsRef` (and `AsMut`) implementations, preserving the `const` status of the original `get_mut`, albeit only unstably.
This completes the existing suite of `as_ref`, `as_mut`, and `as_pin_mut` methods.
e2f838b to
57d4965
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This should probably be an ACP. You would also need to demonstrate that this impl is useful in practice. |
|
@bors r+ |
|
⌛ Testing commit 57d4965 with merge 7654d3b... Workflow: https://github.com/rust-lang/rust/actions/runs/24176039890 |
core::sync: rename `Exclusive` to `SyncView` and make improvements This PR implements the renaming of `core::sync::Exclusive` to `SyncView` as decided in #98407. To preserve the ability to search for the old name, it adds `Exclusive` as a `doc_alias`. It also makes the following additional changes: - Converting the `get_mut` method to being an instance of `AsMut::as_mut`. In the process, it makes both the new `impl AsMut` and the existing `impl AsRef` `const`, and it also renames `get_pin_mut` to `as_pin_mut` for consistency. This direction follows a suggestion from #98407. - Adding an `as_pin` method that can only be used when the wrapped type implements `Sync`, to complete the square of access methods. - Making as many of the existing `impl`s `const` as possible; this involved making the existing `impl Default` no longer derived. - Adding `impl`s for `AsyncFnOnce`, `AsyncFnMut`, and `AsyncFn`, akin to the existing `impls` for `FnOnce`, `FnMut`, and `Fn`. It does not yet do the following, which may be desirable: - Fixing/improving the documentation to address the concern pointed out in #146245. It previously did the following, but this was removed after discussion: - Adding an `impl` for (`const`) `Iterator`, which felt in line with the existing `impl`s for `Future` and `Coroutine`.
|
Yielding to encompassing rollup @bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #155029. |
Rollup merge of #153038 - pthariensflame:syncview-rename, r=Amanieu core::sync: rename `Exclusive` to `SyncView` and make improvements This PR implements the renaming of `core::sync::Exclusive` to `SyncView` as decided in #98407. To preserve the ability to search for the old name, it adds `Exclusive` as a `doc_alias`. It also makes the following additional changes: - Converting the `get_mut` method to being an instance of `AsMut::as_mut`. In the process, it makes both the new `impl AsMut` and the existing `impl AsRef` `const`, and it also renames `get_pin_mut` to `as_pin_mut` for consistency. This direction follows a suggestion from #98407. - Adding an `as_pin` method that can only be used when the wrapped type implements `Sync`, to complete the square of access methods. - Making as many of the existing `impl`s `const` as possible; this involved making the existing `impl Default` no longer derived. - Adding `impl`s for `AsyncFnOnce`, `AsyncFnMut`, and `AsyncFn`, akin to the existing `impls` for `FnOnce`, `FnMut`, and `Fn`. It does not yet do the following, which may be desirable: - Fixing/improving the documentation to address the concern pointed out in #146245. It previously did the following, but this was removed after discussion: - Adding an `impl` for (`const`) `Iterator`, which felt in line with the existing `impl`s for `Future` and `Coroutine`.
View all comments
This PR implements the renaming of
core::sync::ExclusivetoSyncViewas decided in #98407. To preserve the ability to search for the old name, it addsExclusiveas adoc_alias.It also makes the following additional changes:
get_mutmethod to being an instance ofAsMut::as_mut. In the process, it makes both the newimpl AsMutand the existingimpl AsRefconst, and it also renamesget_pin_muttoas_pin_mutfor consistency. This direction follows a suggestion from Tracking Issue forExclusive#98407.as_pinmethod that can only be used when the wrapped type implementsSync, to complete the square of access methods.implsconstas possible; this involved making the existingimpl Defaultno longer derived.impls forAsyncFnOnce,AsyncFnMut, andAsyncFn, akin to the existingimplsforFnOnce,FnMut, andFn.It does not yet do the following, which may be desirable:
std::sync::Exclusiveis dubious #146245.It previously did the following, but this was removed after discussion:
implfor (const)Iterator, which felt in line with the existingimpls forFutureandCoroutine.