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

Implement PointerLike for isize, NonNull, Cell, UnsafeCell, and SyncUnsafeCell. #134642

Merged
merged 1 commit into from
Dec 23, 2024

Conversation

kpreid
Copy link
Contributor

@kpreid kpreid commented Dec 22, 2024

  • Implementing PointerLike for UnsafeCell enables the possibility of interior mutable dyn* values. Since this means potentially exercising new codegen behavior, I added a test for it in tests/ui/dyn-star/cell.rs. Please let me know if there are further sorts of tests that should be written, or other care that should be taken with this change.

    It is unfortunately not possible without compiler changes to implement PointerLike for Atomic* types, since they are not repr(transparent) (and, in theory if not in practice, AtomicUsize's alignment may be greater than that of an ordinary pointer or usize).

  • Implementing PointerLike for NonNull is useful for pointer types which wrap NonNull.

  • Implementing PointerLike for isize is just for completeness; I have no use cases in mind, but I cannot think of any reason not to do this.

  • Tracking issue: Tracking issue for dyn-star #102425

@rustbot label +F-dyn_star
(there is no label or tracking issue for F-pointer_like_trait)

@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2024

r? @lcnr

rustbot has assigned @lcnr.
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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. F-dyn_star `#![feature(dyn_star)]` labels Dec 22, 2024
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

compiler-errors commented Dec 22, 2024

pls squash this into one commit, then i can approve -- 4 commits is definitely a bit excessive to touch a few of impls

… and `SyncUnsafeCell`.

Implementing `PointerLike` for `UnsafeCell` enables the possibility of
interior mutable `dyn*` values. Since this means potentially exercising
new codegen behavior, I added a test for it in `tests/ui/dyn-star/cell.rs`.

Also updated UI tests to account for the `isize` implementation changing
error messages.
@kpreid
Copy link
Contributor Author

kpreid commented Dec 22, 2024

Squashed. I was refraining from squashing/amending because I had been previously advised that PRs actively in review should not be force-pushed to avoid losing context for review comments; if it were up to my choice I would be doing a lot more rebasing and amending.

@compiler-errors
Copy link
Member

No worries. This PR is like 6 files large; I have no trouble maintaining the state here.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 22, 2024

📌 Commit 5c04151 has been approved by compiler-errors

It is now in the queue for this repository.

@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 Dec 22, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 22, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#130289 (docs: Permissions.readonly() also ignores root user special permissions)
 - rust-lang#134583 (docs: `transmute<&mut T, &mut MaybeUninit<T>>` is unsound when exposed to safe code)
 - rust-lang#134611 (Align `{i686,x86_64}-win7-windows-msvc` to their parent targets)
 - rust-lang#134629 (compiletest: Allow using a specific debugger when running debuginfo tests)
 - rust-lang#134642 (Implement `PointerLike` for `isize`, `NonNull`, `Cell`, `UnsafeCell`, and `SyncUnsafeCell`.)
 - rust-lang#134660 (Fix spacing of markdown code block fences in compiler rustdoc)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 23, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#130289 (docs: Permissions.readonly() also ignores root user special permissions)
 - rust-lang#134583 (docs: `transmute<&mut T, &mut MaybeUninit<T>>` is unsound when exposed to safe code)
 - rust-lang#134611 (Align `{i686,x86_64}-win7-windows-msvc` to their parent targets)
 - rust-lang#134629 (compiletest: Allow using a specific debugger when running debuginfo tests)
 - rust-lang#134642 (Implement `PointerLike` for `isize`, `NonNull`, `Cell`, `UnsafeCell`, and `SyncUnsafeCell`.)
 - rust-lang#134660 (Fix spacing of markdown code block fences in compiler rustdoc)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c16f00c into rust-lang:master Dec 23, 2024
6 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Dec 23, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 23, 2024
Rollup merge of rust-lang#134642 - kpreid:pointerlike-cell, r=compiler-errors

Implement `PointerLike` for `isize`, `NonNull`, `Cell`, `UnsafeCell`, and `SyncUnsafeCell`.

* Implementing `PointerLike` for `UnsafeCell` enables the possibility of interior mutable `dyn*` values. Since this means potentially exercising new codegen behavior, I added a test for it in `tests/ui/dyn-star/cell.rs`. Please let me know if there are further sorts of tests that should be written, or other care that should be taken with this change.

  It is unfortunately not possible without compiler changes to implement `PointerLike` for `Atomic*` types, since they are not `repr(transparent)` (and, in theory if not in practice, `AtomicUsize`'s alignment may be greater than that of an ordinary pointer or `usize`).

* Implementing `PointerLike` for `NonNull` is useful for pointer types which wrap `NonNull`.

* Implementing `PointerLike` for `isize` is just for completeness; I have no use cases in mind, but I cannot think of any reason not to do this.

* Tracking issue: rust-lang#102425

`@rustbot` label +F-dyn_star
(there is no label or tracking issue for F-pointer_like_trait)
@kpreid kpreid deleted the pointerlike-cell branch December 23, 2024 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-dyn_star `#![feature(dyn_star)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants