Skip to content

Implement Box::as_non_null().#157347

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
theemathas:box-as-non-null
Jul 1, 2026
Merged

Implement Box::as_non_null().#157347
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
theemathas:box-as-non-null

Conversation

@theemathas

Copy link
Copy Markdown
Contributor

ACP: rust-lang/libs-team#799
Tracking issue: #157345

The docs are mostly copied from Box::as_mut_ptr()

I also made a drive-by change to add #[must_use] to Box::as_{ptr, mut_ptr}.

I'm unsure what #[rustc_never_returns_null_ptr] and #[rustc_as_ptr] do. Should Box::as_non_null() be annotated with them?

r? libs-api

@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 Jun 3, 2026
@theemathas

Copy link
Copy Markdown
Contributor Author

#[rustc_as_ptr] is used by the dangling_pointers_from_temporaries lint. So, Box::as_non_null should have the attribute. See also 24e92dc (#157226).

I'm unsure about #[rustc_never_returns_null_ptr] though.

@rust-bors

This comment has been minimized.

ACP: <rust-lang/libs-team#799>
Tracking issue: <rust-lang#157345>

The docs are mostly copied from `Box::as_mut_ptr()`
@rustbot

rustbot commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

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.

@theemathas

Copy link
Copy Markdown
Contributor Author

@rustbot reroll

@rustbot rustbot assigned LawnGnome and unassigned the8472 Jun 18, 2026
@theemathas

Copy link
Copy Markdown
Contributor Author

I think that #[rustc_never_returns_null_ptr] isn't needed, since the function returns a NonNull, which already guarantees the result to be non-null.

@theemathas

Copy link
Copy Markdown
Contributor Author

I'm told that libs-api doesn't do reviews. Oops.

r? libs

@rustbot rustbot assigned Darksonn and unassigned LawnGnome Jun 30, 2026

@Darksonn Darksonn left a comment

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.

Looks good to me. I agree with the PRs current choice of annotating with #[rustc_as_ptr] but not #[rustc_never_returns_null_ptr].

@bors r+ rollup

View changes since this review

@rust-bors

rust-bors Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5a39872 has been approved by Darksonn

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1. This pull request will be tested once the tree is reopened.

@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 Jun 30, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 30, 2026
…sonn

Implement `Box::as_non_null()`.

ACP: <rust-lang/libs-team#799>
Tracking issue: <rust-lang#157345>

The docs are mostly copied from `Box::as_mut_ptr()`

I also made a drive-by change to add `#[must_use]` to `Box::as_{ptr, mut_ptr}`.

I'm unsure what `#[rustc_never_returns_null_ptr]` and `#[rustc_as_ptr]` do. Should `Box::as_non_null()` be annotated with them?

r? libs-api
rust-bors Bot pushed a commit that referenced this pull request Jun 30, 2026
…uwer

Rollup of 3 pull requests

Successful merges:

 - #156379 (lint on `core::ffi::c_void` as a return type)
 - #157347 (Implement `Box::as_non_null()`.)
 - #158614 (Fix error message when rejecting implicit stage != 2 in CI)
rust-bors Bot pushed a commit that referenced this pull request Jun 30, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #156379 (lint on `core::ffi::c_void` as a return type)
 - #157347 (Implement `Box::as_non_null()`.)
 - #157650 (rustc_target: Add OpenEmbedded/Yocto Linux base targets)
 - #158569 ([rustdoc] Fix handling of inlining of `no_inline` of foreign items)
 - #158573 (stabilize `feature(atomic_from_mut)`)
 - #158614 (Fix error message when rejecting implicit stage != 2 in CI)
 - #158616 (Remove dependency from `rustc_metadata` on `rustc_incremental`)
@rust-bors rust-bors Bot merged commit b3bc402 into rust-lang:main Jul 1, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jul 1, 2026
rust-timer added a commit that referenced this pull request Jul 1, 2026
Rollup merge of #157347 - theemathas:box-as-non-null, r=Darksonn

Implement `Box::as_non_null()`.

ACP: <rust-lang/libs-team#799>
Tracking issue: <#157345>

The docs are mostly copied from `Box::as_mut_ptr()`

I also made a drive-by change to add `#[must_use]` to `Box::as_{ptr, mut_ptr}`.

I'm unsure what `#[rustc_never_returns_null_ptr]` and `#[rustc_as_ptr]` do. Should `Box::as_non_null()` be annotated with them?

r? libs-api
@theemathas theemathas deleted the box-as-non-null branch July 1, 2026 03:23
bjorn3 pushed a commit to bjorn3/miri that referenced this pull request Jul 1, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#156379 (lint on `core::ffi::c_void` as a return type)
 - rust-lang/rust#157347 (Implement `Box::as_non_null()`.)
 - rust-lang/rust#157650 (rustc_target: Add OpenEmbedded/Yocto Linux base targets)
 - rust-lang/rust#158569 ([rustdoc] Fix handling of inlining of `no_inline` of foreign items)
 - rust-lang/rust#158573 (stabilize `feature(atomic_from_mut)`)
 - rust-lang/rust#158614 (Fix error message when rejecting implicit stage != 2 in CI)
 - rust-lang/rust#158616 (Remove dependency from `rustc_metadata` on `rustc_incremental`)
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 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.

5 participants