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

Add from_ref and from_mut constructors to core::ptr::NonNull. #130822

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

bjoernager
Copy link
Contributor

@bjoernager bjoernager commented Sep 25, 2024

Relevant tracking issue: #130823

The core::ptr::NonNull type should have the convenience constructors from_ref and from_mut for parity with core::ptr::from_ref and core::ptr::from_mut.

Although the type in question already implements From<&T> and From<&mut T>, these new functions also carry the ability to be used in constant expressions (due to not being behind a trait).

@rustbot
Copy link
Collaborator

rustbot commented Sep 25, 2024

r? @joboet

rustbot has assigned @joboet.
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-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 25, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@tgross35
Copy link
Contributor

tgross35 commented Sep 25, 2024

This will need an ACP, or at least libs-api signoff. An ACP is just an issue template at https://github.com/rust-lang/libs-team/.

This PR additionally adds the must_use attribute to the new_unchecked and new constructors.

Should probably be moved to its own commit to keep updates from that and updates from the new API separate (e.g. the MIR test needs to be blessed)

@bjoernager
Copy link
Contributor Author

I've removed the must_use attributes and will PR them for independent review at another time.

@rust-log-analyzer

This comment has been minimized.

@dtolnay dtolnay added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 16, 2024
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.

Thank you!

@dtolnay
Copy link
Member

dtolnay commented Oct 16, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Oct 16, 2024

📌 Commit 94ab726 has been approved by dtolnay

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

Rollup of 8 pull requests

Successful merges:

 - rust-lang#130822 (Add `from_ref` and `from_mut` constructors to `core::ptr::NonNull`.)
 - rust-lang#131381 (Implement edition 2024 match ergonomics restrictions)
 - rust-lang#131594 (rustdoc: Rename "object safe" to "dyn compatible")
 - rust-lang#131686 (Add fast-path when computing the default visibility)
 - rust-lang#131699 (Try to improve error messages involving aliases in the solver)
 - rust-lang#131757 (Ignore lint-non-snake-case-crate#proc_macro_ on targets without unwind)
 - rust-lang#131783 (Fix explicit_iter_loop in rustc_serialize)
 - rust-lang#131788 (Fix mismatched quotation mark)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1817de6 into rust-lang:master Oct 16, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 16, 2024
Rollup merge of rust-lang#130822 - bjoernager:non-null-from-ref, r=dtolnay

Add `from_ref` and `from_mut` constructors to `core::ptr::NonNull`.

Relevant tracking issue: rust-lang#130823

The `core::ptr::NonNull` type should have the convenience constructors `from_ref` and `from_mut` for parity with `core::ptr::from_ref` and `core::ptr::from_mut`.

Although the type in question already implements `From<&T>` and `From<&mut T>`, these new functions also carry the ability to be used in constant expressions (due to not being behind a trait).
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. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants