Skip to content

implement Box::take - #147227

Merged
bors merged 1 commit into
rust-lang:masterfrom
edwloef:box_take
Oct 2, 2025
Merged

implement Box::take#147227
bors merged 1 commit into
rust-lang:masterfrom
edwloef:box_take

Conversation

@edwloef

Copy link
Copy Markdown
Contributor

Tracking issue: #147212

I'm not entirely sure about the wording of the doc comment, if anyone has any suggestions that'd be great :)

@rustbotrustbot 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 Oct 1, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

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

@edwloefedwloef mentioned this pull request Oct 1, 2025
4 tasks
@rust-langrust-lang deleted a comment from borsOct 1, 2025

@joboetjoboet 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.

The current wording is great! I'd maybe add a note (and a line in the example) about using Box::write to reinitialise the Box, as these functions are meant to be used together.

View changes since this review

let (raw, alloc) = Box::into_raw_with_allocator(boxed);
let value = raw.read();
let uninit = Box::from_raw_in(raw.cast::<mem::MaybeUninit<T>>(), alloc);
(value, uninit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you use Box::into_non_null_with_allocator and NonNull::cast_uninit?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Sure! However since this has already been r+'ed, I think I'll save that change for the inevitable renaming of the function, since as far as I can tell the semantics are identical from the outside.

@QelxirosQelxiros mentioned this pull request Oct 1, 2025
@joboet

Copy link
Copy Markdown
Member

Thanks!
@bors r+ rollup

@bors

bors commented Oct 1, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 8dfea22 has been approved by joboet

It is now in the queue for this repository.

@borsbors 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 1, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 2, 2025
implement `Box::take`
Tracking issue: rust-lang#147212
I'm not entirely sure about the wording of the doc comment, if anyone has any suggestions that'd be great :)
@ZalatharZalathar mentioned this pull request Oct 2, 2025
bors added a commit that referenced this pull request Oct 2, 2025
Rollup of 10 pull requests
Successful merges:
- #146281 (Support `#[rustc_align_static]` inside `thread_local!`)
- #146535 (mbe: Implement `unsafe` attribute rules)
- #146585 (indexing: reword help)
- #147004 (Tweak handling of "struct like start" where a struct isn't supported)
- #147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
- #147225 (Don't enable shared memory by default with Wasm atomics)
- #147227 (implement `Box::take`)
- #147231 (Extending `#[rustc_force_inline]` to be applicable to inherent methods)
- #147233 (Initialize llvm submodule if not already the case to run citool)
- #147236 (Update books)
r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 2, 2025
implement `Box::take`
Tracking issue: rust-lang#147212
I'm not entirely sure about the wording of the doc comment, if anyone has any suggestions that'd be great :)
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 2, 2025
implement `Box::take`
Tracking issue: rust-lang#147212
I'm not entirely sure about the wording of the doc comment, if anyone has any suggestions that'd be great :)
@jhprattjhpratt mentioned this pull request Oct 2, 2025
bors added a commit that referenced this pull request Oct 2, 2025
Rollup of 9 pull requests
Successful merges:
- #146281 (Support `#[rustc_align_static]` inside `thread_local!`)
- #146535 (mbe: Implement `unsafe` attribute rules)
- #146585 (indexing: reword help)
- #147004 (Tweak handling of "struct like start" where a struct isn't supported)
- #147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
- #147225 (Don't enable shared memory by default with Wasm atomics)
- #147227 (implement `Box::take`)
- #147233 (Initialize llvm submodule if not already the case to run citool)
- #147236 (Update books)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit fbe6834 into rust-lang:masterOct 2, 2025
10 checks passed
@rustbotrustbot added this to the 1.92.0 milestone Oct 2, 2025
rust-timer added a commit that referenced this pull request Oct 2, 2025
Rollup merge of #147227 - edwloef:box_take, r=joboet
implement `Box::take`
Tracking issue: #147212
I'm not entirely sure about the wording of the doc comment, if anyone has any suggestions that'd be great :)
@edwloef
edwloef deleted the box_take branch October 2, 2025 20:47
github-actionsBot pushed a commit to rust-lang/miri that referenced this pull request Oct 3, 2025
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#146281 (Support `#[rustc_align_static]` inside `thread_local!`)
- rust-lang/rust#146535 (mbe: Implement `unsafe` attribute rules)
- rust-lang/rust#146585 (indexing: reword help)
- rust-lang/rust#147004 (Tweak handling of "struct like start" where a struct isn't supported)
- rust-lang/rust#147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
- rust-lang/rust#147225 (Don't enable shared memory by default with Wasm atomics)
- rust-lang/rust#147227 (implement `Box::take`)
- rust-lang/rust#147233 (Initialize llvm submodule if not already the case to run citool)
- rust-lang/rust#147236 (Update books)
r? `@ghost`
`@rustbot` modify labels: rollup
github-actionsBot pushed a commit to model-checking/verify-rust-std that referenced this pull request Oct 9, 2025
implement `Box::take`
Tracking issue: rust-lang#147212
I'm not entirely sure about the wording of the doc comment, if anyone has any suggestions that'd be great :)
rust-cloud-vmsBot pushed a commit to makai410/rustc_public that referenced this pull request Oct 12, 2025
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#146281 (Support `#[rustc_align_static]` inside `thread_local!`)
- rust-lang/rust#146535 (mbe: Implement `unsafe` attribute rules)
- rust-lang/rust#146585 (indexing: reword help)
- rust-lang/rust#147004 (Tweak handling of "struct like start" where a struct isn't supported)
- rust-lang/rust#147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
- rust-lang/rust#147225 (Don't enable shared memory by default with Wasm atomics)
- rust-lang/rust#147227 (implement `Box::take`)
- rust-lang/rust#147233 (Initialize llvm submodule if not already the case to run citool)
- rust-lang/rust#147236 (Update books)
r? `@ghost`
`@rustbot` modify labels: rollup
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Oct 18, 2025
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#146281 (Support `#[rustc_align_static]` inside `thread_local!`)
- rust-lang/rust#146535 (mbe: Implement `unsafe` attribute rules)
- rust-lang/rust#146585 (indexing: reword help)
- rust-lang/rust#147004 (Tweak handling of "struct like start" where a struct isn't supported)
- rust-lang/rust#147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
- rust-lang/rust#147225 (Don't enable shared memory by default with Wasm atomics)
- rust-lang/rust#147227 (implement `Box::take`)
- rust-lang/rust#147233 (Initialize llvm submodule if not already the case to run citool)
- rust-lang/rust#147236 (Update books)
r? `@ghost`
`@rustbot` modify labels: rollup
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 8, 2025
implement `Box::take`
Tracking issue: rust-lang#147212
I'm not entirely sure about the wording of the doc comment, if anyone has any suggestions that'd be great :)
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 8, 2025
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#146281 (Support `#[rustc_align_static]` inside `thread_local!`)
- rust-lang#146535 (mbe: Implement `unsafe` attribute rules)
- rust-lang#146585 (indexing: reword help)
- rust-lang#147004 (Tweak handling of "struct like start" where a struct isn't supported)
- rust-lang#147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
- rust-lang#147225 (Don't enable shared memory by default with Wasm atomics)
- rust-lang#147227 (implement `Box::take`)
- rust-lang#147233 (Initialize llvm submodule if not already the case to run citool)
- rust-lang#147236 (Update books)
r? `@ghost`
`@rustbot` modify labels: rollup
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 10, 2025
implement `Box::take`
Tracking issue: rust-lang#147212
I'm not entirely sure about the wording of the doc comment, if anyone has any suggestions that'd be great :)
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 10, 2025
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#146281 (Support `#[rustc_align_static]` inside `thread_local!`)
- rust-lang#146535 (mbe: Implement `unsafe` attribute rules)
- rust-lang#146585 (indexing: reword help)
- rust-lang#147004 (Tweak handling of "struct like start" where a struct isn't supported)
- rust-lang#147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
- rust-lang#147225 (Don't enable shared memory by default with Wasm atomics)
- rust-lang#147227 (implement `Box::take`)
- rust-lang#147233 (Initialize llvm submodule if not already the case to run citool)
- rust-lang#147236 (Update books)
r? `@ghost`
`@rustbot` modify labels: rollup
@edwloefedwloef mentioned this pull request Nov 12, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 13, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 13, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 14, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 14, 2025
rust-timer added a commit that referenced this pull request Nov 14, 2025
Rollup merge of #148867 - edwloef:refactor-box-take, r=joboet
Refactor `Box::take`
as per #147227 (comment)
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Nov 16, 2025
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#146281 (Support `#[rustc_align_static]` inside `thread_local!`)
- rust-lang/rust#146535 (mbe: Implement `unsafe` attribute rules)
- rust-lang/rust#146585 (indexing: reword help)
- rust-lang/rust#147004 (Tweak handling of "struct like start" where a struct isn't supported)
- rust-lang/rust#147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
- rust-lang/rust#147225 (Don't enable shared memory by default with Wasm atomics)
- rust-lang/rust#147227 (implement `Box::take`)
- rust-lang/rust#147233 (Initialize llvm submodule if not already the case to run citool)
- rust-lang/rust#147236 (Update books)
r? `@ghost`
`@rustbot` modify labels: rollup
github-actionsBot pushed a commit to model-checking/verify-rust-std that referenced this pull request Nov 30, 2025
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Mar 27, 2026
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#146281 (Support `#[rustc_align_static]` inside `thread_local!`)
- rust-lang/rust#146535 (mbe: Implement `unsafe` attribute rules)
- rust-lang/rust#146585 (indexing: reword help)
- rust-lang/rust#147004 (Tweak handling of "struct like start" where a struct isn't supported)
- rust-lang/rust#147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
- rust-lang/rust#147225 (Don't enable shared memory by default with Wasm atomics)
- rust-lang/rust#147227 (implement `Box::take`)
- rust-lang/rust#147233 (Initialize llvm submodule if not already the case to run citool)
- rust-lang/rust#147236 (Update books)
r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libsRelevant 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

@edwloef@rustbot@joboet@bors@camsteffen