Skip to content

core::sync: rename Exclusive to SyncView and make improvements#153038

Open
pthariensflame wants to merge 8 commits intorust-lang:mainfrom
pthariensflame:syncview-rename
Open

core::sync: rename Exclusive to SyncView and make improvements#153038
pthariensflame wants to merge 8 commits intorust-lang:mainfrom
pthariensflame:syncview-rename

Conversation

@pthariensflame
Copy link
Contributor

@pthariensflame pthariensflame commented Feb 24, 2026

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 Tracking Issue for Exclusive #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 impls const as possible; this involved making the existing impl Default no longer derived.
  • Adding an impl for (const) Iterator, which felt in line with the existing impls for Future and Coroutine.
  • Adding impls 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:

@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 Feb 24, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 24, 2026

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: @scottmcm, libs
  • @scottmcm, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, joboet, scottmcm

@rust-log-analyzer

This comment has been minimized.

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.
@rustbot rustbot added F-explicit_tail_calls `#![feature(explicit_tail_calls)]` WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Feb 24, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 24, 2026

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.

#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
impl<T> const Iterator for SyncView<T>
where
T: [const] Iterator + ?Sized,
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be bounded on Syncsize_hint takes &self.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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).

@WaffleLapkin WaffleLapkin removed the F-explicit_tail_calls `#![feature(explicit_tail_calls)]` label Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants