Skip to content

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

Merged
rust-bors[bot] merged 7 commits intorust-lang:mainfrom
pthariensflame:syncview-rename
Apr 9, 2026
Merged

core::sync: rename Exclusive to SyncView and make improvements#153038
rust-bors[bot] merged 7 commits intorust-lang:mainfrom
pthariensflame:syncview-rename

Conversation

@pthariensflame
Copy link
Copy Markdown
Contributor

@pthariensflame pthariensflame commented Feb 24, 2026

View all comments

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 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:

It previously did the following, but this was removed after discussion:

  • Adding an impl for (const) Iterator, which felt in line with the existing impls for Future and Coroutine.

@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
Copy Markdown
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.

@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

This comment has been minimized.

#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
impl<T> const Iterator for SyncView<T>
where
T: [const] Iterator + ?Sized,
Copy link
Copy Markdown
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
Copy Markdown
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
@pthariensflame
Copy link
Copy Markdown
Contributor Author

Since you’re already here and reviewing it anyway, may as well make it official:

r? @joboet

@rustbot rustbot assigned joboet and unassigned Mark-Simulacrum Feb 26, 2026
@rustbot rustbot added the F-explicit_tail_calls `#![feature(explicit_tail_calls)]` label Feb 27, 2026
@rustbot

This comment has been minimized.

@joboet
Copy link
Copy Markdown
Member

joboet commented Feb 28, 2026

r? libs-api
This will need oversight from libs-api (and I'm not sure whether it is a good idea to do all these things in a single PR).

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Feb 28, 2026
@rustbot rustbot assigned Amanieu and unassigned joboet Feb 28, 2026
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@Amanieu
Copy link
Copy Markdown
Member

Amanieu commented Apr 6, 2026

This mostly LGTM, except for the Iterator impl which feels suspicious for the reasons @joboet mentioned. I would prefer if that impl was removed for now.

@pthariensflame
Copy link
Copy Markdown
Contributor Author

pthariensflame commented Apr 7, 2026

This mostly LGTM, except for the Iterator impl which feels suspicious for the reasons @joboet mentioned. I would prefer if that impl was removed for now.

We will remove it, then; what would be the best way for us to bring up the impl for a closer look/discussion, since this PR seems like the wrong place for it?

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
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 7, 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.

@Amanieu
Copy link
Copy Markdown
Member

Amanieu commented Apr 9, 2026

We will remove it, then; what would be the best way for us to bring up the impl for a closer look/discussion, since this PR seems like the wrong place for it?

This should probably be an ACP. You would also need to demonstrate that this impl is useful in practice.

@Amanieu
Copy link
Copy Markdown
Member

Amanieu commented Apr 9, 2026

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 9, 2026

📌 Commit 57d4965 has been approved by Amanieu

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 9, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 9, 2026

⌛ Testing commit 57d4965 with merge 7654d3b...

Workflow: https://github.com/rust-lang/rust/actions/runs/24176039890

rust-bors bot pushed a commit that referenced this pull request Apr 9, 2026
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`.
@jhpratt
Copy link
Copy Markdown
Member

jhpratt commented Apr 9, 2026

Yielding to encompassing rollup

@bors yield

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 9, 2026

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #155029.

rust-bors bot pushed a commit that referenced this pull request Apr 9, 2026
Rollup of 3 pull requests

Successful merges:

 - #153038 (core::sync: rename `Exclusive` to `SyncView` and make improvements)
 - #154955 (Fix pattern types rendering in rustdoc)
 - #155026 (Move `maybe_loop_headers` out of `rustc_middle`.)
@rust-bors rust-bors bot merged commit 9ebe418 into rust-lang:main Apr 9, 2026
11 of 12 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 9, 2026
rust-timer added a commit that referenced this pull request Apr 9, 2026
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-explicit_tail_calls `#![feature(explicit_tail_calls)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API 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.

8 participants